mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-08 09:41:35 +00:00
service: Capture stdout/stderr when running as systemd unit
- Avoid duplicate log messages by not logging to console when running as systemd unit. - Retain normal logging when running on the terminal. Tests: - When running as systemd unit, output to stdin/stdout is captured in systemd journal and visible with 'sudo freedombox-logs'. - When running on terminal manually with 'sudo --user plinth ./run --develop' both log messages and stdout/stderr prints() are visible. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
c0d603af07
commit
cc626be728
@ -17,8 +17,6 @@ RestartSec=5
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
User=plinth
|
||||
Group=plinth
|
||||
StandardOutput=null
|
||||
StandardError=null
|
||||
NotifyAccess=main
|
||||
# Uploaded files in /var/tmp/ are shared with FreedomBox privileged service by
|
||||
# joining namespaces.
|
||||
|
||||
@ -5,6 +5,7 @@ Setup logging for the application.
|
||||
|
||||
import logging
|
||||
import logging.config
|
||||
import sys
|
||||
import typing
|
||||
import warnings
|
||||
|
||||
@ -158,5 +159,11 @@ def get_configuration():
|
||||
}
|
||||
}
|
||||
}
|
||||
if not sys.stdin.isatty():
|
||||
# If running on a console, say due to user manually starting it, then
|
||||
# log everything to console. However, if we are running as a systemd
|
||||
# unit then no need to log to console. This allows us to capture
|
||||
# stdout/stderr in systemd unit without repeating the log messages.
|
||||
configuration['root']['handlers'].remove('console')
|
||||
|
||||
return configuration
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user