[systemd-devel] How to run forking daemon with systemd in correct way, without errors?

Lennart Poettering lennart at poettering.net
Thu Nov 23 14:47:15 UTC 2017


On Do, 23.11.17 12:40, Gena Makhomed (gmm at csdoc.com) wrote:

> On 23.11.2017 2:30, Reindl Harald wrote:
> 
> > > > > > or just remove the pid-file stuff from the systemd-unit,
> > > > > > systemd don't need it really
> 
> > > You are talking about GuessMainPID= option?
> 
> > no i talk about nearly 6 years systemd expierience in production and
> > that i yet need to see a real world case where systemd don't work in
> > case of missing PID file
> 
> You are argue not with me, you are argue with systemd documentation:
> 
> "...it is recommended to also use the PIDFile= option, so that systemd can
> identify the main process of the daemon" -
> https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=

If you use Type=forking, then you'll get away with not specifiying a
PID file in most cases, but it's racy as soon as you have more than
one daemon process, and nginx appears to be one of this kind, hence
please specify PIDFile=.

> Creating pid file from grandchild process is common UNIX pattern.
> 
> Thousands of daemons are working in this way. Rewrite them all?

Well, the better written ones synchronize properly.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list