[systemd-devel] How to run forking daemon with systemd in correct way, without errors?
Gena Makhomed
gmm at csdoc.com
Thu Nov 23 11:00:13 UTC 2017
On 23.11.2017 11:52, Clemens Gruber wrote:
> Can you try this on a newer systemd version? Yours is pretty old.
> I'm on systemd 235 (ArchLinux).
> Maybe systemd 219 behaved differently for forking services?
This is does not help, as I understand from the latest systemd sources
- this is common systemd behaviour and it is not changed in new version.
> I don't think nginx is doing anything wrong. This is working fine for
> many people with and without systemd. There is even a similar example on
> the nginx website:
> https://www.nginx.com/resources/wiki/start/topics/examples/systemd/
From systemd developers point of view this is bug in nginx source code.
From nginx developers point of view this is may be bug in systemd code.
Systemd expects what parent nginx process exits only when pid file
with child process pid already exists.
https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=
Type=
If set to forking, it is expected that the process configured with
ExecStart= will call fork() as part of its start-up. The parent process
is expected to exit when start-up is complete and all communication
channels are set up. The child continues to run as the main daemon
process. This is the behavior of traditional UNIX daemons. If this
setting is used, it is recommended to also use the PIDFile= option, so
that systemd can identify the main process of the daemon. systemd will
proceed with starting follow-up units as soon as the parent process exits.
--
Best regards,
Gena
More information about the systemd-devel
mailing list