Some containers lack /dev/console, so when multi_log attempts to open
that device and write to it directly things can start going haywire. Here we address this problem by sending console-bound output to stdout and letting init take care of getting it to the console instead. We already configure upstart with "console output", so we need only change systemd to use "journal+console".
This commit is contained in:
@@ -360,11 +360,11 @@ def multi_log(text, console=True, stderr=True,
|
|||||||
if stderr:
|
if stderr:
|
||||||
sys.stderr.write(text)
|
sys.stderr.write(text)
|
||||||
if console:
|
if console:
|
||||||
# Don't use the write_file since
|
# Some containers lack /dev/console, so we send output to
|
||||||
# this might be 'sensitive' info (not debug worthy?)
|
# stdout and configure upstart with "console output" and
|
||||||
with open('/dev/console', 'wb') as wfh:
|
# systemd with "journal+console" and let them take care of
|
||||||
wfh.write(text)
|
# getting output to the console.
|
||||||
wfh.flush()
|
print text
|
||||||
if log:
|
if log:
|
||||||
if text[-1] == "\n":
|
if text[-1] == "\n":
|
||||||
log.log(log_level, text[:-1])
|
log.log(log_level, text[:-1])
|
||||||
|
@@ -11,7 +11,7 @@ RemainAfterExit=yes
|
|||||||
TimeoutSec=0
|
TimeoutSec=0
|
||||||
|
|
||||||
# Output needs to appear in instance console output
|
# Output needs to appear in instance console output
|
||||||
StandardOutput=tty
|
StandardOutput=journal+console
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
@@ -11,7 +11,7 @@ RemainAfterExit=yes
|
|||||||
TimeoutSec=0
|
TimeoutSec=0
|
||||||
|
|
||||||
# Output needs to appear in instance console output
|
# Output needs to appear in instance console output
|
||||||
StandardOutput=tty
|
StandardOutput=journal+console
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
@@ -10,7 +10,7 @@ RemainAfterExit=yes
|
|||||||
TimeoutSec=0
|
TimeoutSec=0
|
||||||
|
|
||||||
# Output needs to appear in instance console output
|
# Output needs to appear in instance console output
|
||||||
StandardOutput=tty
|
StandardOutput=journal+console
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
@@ -11,7 +11,7 @@ RemainAfterExit=yes
|
|||||||
TimeoutSec=0
|
TimeoutSec=0
|
||||||
|
|
||||||
# Output needs to appear in instance console output
|
# Output needs to appear in instance console output
|
||||||
StandardOutput=tty
|
StandardOutput=journal+console
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
Reference in New Issue
Block a user