[systemd-devel] How to run forking daemon with systemd in correct way, without errors?
Lennart Poettering
lennart at poettering.net
Thu Nov 23 14:38:17 UTC 2017
On Mi, 22.11.17 22:27, Reindl Harald (h.reindl at thelounge.net) wrote:
> Am 22.11.2017 um 21:37 schrieb Gena Makhomed:
> > I am use nginx web server (http://nginx.org/) with systemd.
> > But I see errors in /var/log/messages when running nginx:
> >
> > systemd: Starting nginx - high performance web server...
> > systemd: Failed to read PID from file /var/run/nginx.pid: Invalid argument
> > systemd: Started nginx - high performance web server.
> >
> > systemd: Starting nginx - high performance web server...
> > systemd: PID file /var/run/nginx.pid not readable (yet?) after start.
> > systemd: Started nginx - high performance web server
>
> either the daemon needs to be fixed or just remove the pid-file stuff from
> the systemd-unit, systemd don't need it really
Well, that's not really true. systemd doesn't need it if there's only
a single process around at the moment the daemon parent process
exits. For many simpler daemons that is usually the case, but for
daemons that employ worker processes this might be different. I'd
always recommend people to use PIDFile= if they use Type=forking.
That said, Type=forking is nasty, and does a lot of stuff that is very
much pointless in a systemd environment. If you have a sympathetic
upstream I'd always recommend switching to Type=notify and dropping
PIDFile= in the process, but that requires that the daemon sends
sd_notify("READY=1") when it finished starting up.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list