Hi,

I have a service unit for nginx that uses Type=forking and PIDFile.
That works, but occasionally I see in the log a message like

nginx.service: PID file /run/nginx/nginx.pid not readable (yet?) after
start: No such file or directory

After investigating this father I see the reason for this is that
nginx creates the pid file in a child process, not in the parent (at
least this is how I interpret their code). As the parent may exit and
systemd may respond to it before the child writes the pid, that leads
to the above message.

I can workaround that via replacing ExecStart=/usr/sbin/nginx with
something like:

ExecStart=/bin/sh -c "set -e; /usr/sbin/nginx; while ! test -s
/run/nginx/nginx.pid; do sleep 0.1; done'

but that busy waits. Is there any option to replace this hack via a
native systemd solution, like explicitly waiting for the pid file to
appear before considering the unit ready?

Regards, Igor Bukanov
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to