gdraheim / docker-systemctl-replacement

docker systemctl replacement - allows to deploy to systemd-controlled containers without starting an actual systemd daemon (e.g. centos7, ubuntu16)
European Union Public License 1.2
1.4k stars 401 forks source link

systemctl does not tail logs anymore immediately after pid 1 receives SIGTERM #182

Open dimikot opened 1 month ago

dimikot commented 1 month ago

Some services have graceful shutdown mechanism, and they print to stdout while they drain. When pid 1 receives SIGTERM (docker container stops), systemctl sends signals to the services and waits until they die. The problem is that whatever the service prints to its stdout/stderr gets swallowed unfortunately.

I think it's because self.print_log_files() (aka read_log_files) is not called anymore after init_loop_until_stop() finishes.

INFO:systemctl:interrupted - exit init-loop
INFO:systemctl:init-loop SIGTERM
INFO:systemctl:system is stopping
INFO:systemctl: stop unit app.service => '/etc/systemd/system/app.service'
INFO:systemctl:no ExecStop => systemctl kill
INFO:systemctl:STATUS /run/app.service.status 11

<<<< I expect app's journal to be tailing here

INFO:systemctl:stop kill PID 73
INFO:systemctl:done kill PID 73 OK