On Thu, May 17, 2018, 12:26 Igor Bukanov <i...@mir2.org> wrote:

> 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?
>

A "native systemd solution" would be to get rid of pidfiles completely.

Have you tried without the PIDFile= setting at all?

Maybe socket-activation would work for you? (With Nginx it's also a hack
though.)

> --

Mantas Mikulėnas
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to