You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
right now, we have a simple systemd service file, for a single process writing logs to stdout. In the near future, the proxy will use a main process with a few worker processes.
Questions:
how to make a service file work correctly with a multiprocess arch?
how to handle logging from the workers?
apparently, there's a KillMode=mixedoption to kill all the process in the cgroup. Ideally, in the case of a restart, the parent process would receive the signal and restart the workers itself, since it knows how to give them the relevant data.
Right now, the workers will log on stdout, but they could send messages to syslog instead.
The systemd service actually "watches" only the main process.
While the main process runs, the service is running,.
When the main process exits 0, the service is noted as success and all the children are killed (unless asked to "RemainAfterExit").
When the main process exits != 0, the service is marked as failed and all the children are killed.
By default, children inherit stdout/stderr from the maain process so everything logged to stdout or stderr go through the main process FDs and are grabbed by systemd. Otherwise syslog is probably the simplest solution.
For the KillMode thing, we use mixed atm for haproxy. man systemd.kill has some info on the options regarding killing processes. Here is the part about KillMode
KillMode=
Specifies how processes of this unit shall be killed. One of control-group, process, mixed, none.
If set to control-group, all remaining processes in the control group of this unit will be killed on unit stop (for services: after the stop command is executed, as configured with ExecStop=). If set to process, only the main process itself is killed. If set to mixed, the SIGTERM signal (see below) is sent to the main process while the subsequent SIGKILL signal (see below) is sent to all remaining processes of the
unit's control group. If set to none, no process is killed. In this case, only the stop command will be executed on unit stop, but no process be killed otherwise. Processes remaining alive after stop are left in their control group and the control group continues to exist after stop unless it is empty.
Processes will first be terminated via SIGTERM (unless the signal to send is changed via KillSignal=). Optionally, this is immediately followed by a SIGHUP (if enabled with SendSIGHUP=). If then, after a delay (configured via the TimeoutStopSec= option), processes still remain, the termination request is repeated with the SIGKILL signal (unless this is disabled via the SendSIGKILL= option). See kill(2) for more
information.
Defaults to control-group.
Regarding the scope feature, you can see it as a "folder" for cgroups.
Scopes units manage a set of system processes. Unlike service units, scope units manage externally created processes, and do not fork off processes on its own.
Long story short:
either we have one service, which forks its children and so on
or we have sevral services launching independent binaries and we can put those into a same scope to regroup all the different components.
The same thing that happens with multithreading, the logs are in the correct order for each process, but with logs from others processes in the middle.
I just want to be sure it would work correctly with sozu and its worker processes (IIRC there was an issue with systemd wanting to manage the workers itself, right?) and the binary upgrades
Do we want/need some kind of "Reload"? I think that would be the correct way to handle sozu upgrades. Do sozu answer to a unix signal for that?
How do we want to handle the "restart"? Should the master process and all of its children be killed?
sozu upgrades are managed by a config message, because it requires a small dance between the master and its workers. I'm not sure that's something systemd can manage correctly
Activity
Geal commentedon Jan 18, 2017
In gitlab by @Geal on Nov 15, 2016, 12:20
is the "scope" feature what we need?
https://www.freedesktop.org/software/systemd/man/systemd.scope.html
https://www.freedesktop.org/wiki/Software/systemd/ControlGroupInterface/
Geal commentedon Jan 18, 2017
In gitlab by @Keruspe on Nov 15, 2016, 14:06
The systemd service actually "watches" only the main process.
While the main process runs, the service is running,.
When the main process exits 0, the service is noted as success and all the children are killed (unless asked to "RemainAfterExit").
When the main process exits != 0, the service is marked as failed and all the children are killed.
By default, children inherit stdout/stderr from the maain process so everything logged to stdout or stderr go through the main process FDs and are grabbed by systemd. Otherwise syslog is probably the simplest solution.
For the KillMode thing, we use mixed atm for haproxy.
man systemd.killhas some info on the options regarding killing processes. Here is the part about KillModeGeal commentedon Jan 18, 2017
In gitlab by @Keruspe on Nov 15, 2016, 14:10
Regarding the scope feature, you can see it as a "folder" for cgroups.
Scopes units manage a set of system processes. Unlike service units, scope units manage externally created processes, and do not fork off processes on its own.
Long story short:
Geal commentedon Jan 18, 2017
In gitlab by @Keruspe on Nov 15, 2016, 14:12
Example of scope: the most common usage is for user sessions, to regroup all the software launched by the user in her session.
Geal commentedon Jan 18, 2017
In gitlab by @Geal on Nov 15, 2016, 14:29
what happens when multiple children write to stdout at the same time?
Geal commentedon Jan 18, 2017
In gitlab by @Keruspe on Nov 15, 2016, 14:33
The same thing that happens with multithreading, the logs are in the correct order for each process, but with logs from others processes in the middle.
Geal commentedon Aug 17, 2017
ok so right now I have this:
Where should I go from there?
cc @Keruspe
Keruspe commentedon Aug 21, 2017
Can you list exactly the things that you want, the behaviour you expect?
Geal commentedon Aug 21, 2017
I just want to be sure it would work correctly with sozu and its worker processes (IIRC there was an issue with systemd wanting to manage the workers itself, right?) and the binary upgrades
Keruspe commentedon Aug 21, 2017
You can give KillMode=mixed a look, apart from that, I don't see any specific recommendation for "basic" usage
Keruspe commentedon Aug 22, 2017
Do we want/need some kind of "Reload"? I think that would be the correct way to handle sozu upgrades. Do sozu answer to a unix signal for that?
How do we want to handle the "restart"? Should the master process and all of its children be killed?
Geal commentedon Aug 22, 2017
sozu upgrades are managed by a config message, because it requires a small dance between the master and its workers. I'm not sure that's something systemd can manage correctly
Geal commentedon Dec 26, 2017
systemd files available in https://github.com/sozu-proxy/sozu/tree/master/os-build/systemd