[systemd-devel] option to wait for pid file to appear

2018-06-08 Thread Jonathan de Boyne Pollard
Mantas Mikulėnas: Maybe socket-activation would work for you? (With Nginx it's also a hack though.) Accept=No Environment=NGINX=3; It is not terrifically complex. The documented way to stop the forking is "daemon off", but an inherited listening socket also does it. * https://bugs.debian.o

Re: [systemd-devel] option to wait for pid file to appear

2018-06-07 Thread Igor Bukanov
On 7 June 2018 at 10:35, Lennart Poettering wrote: > Nah, daemon() does not write PID files, you have to do that in your > own code. As daemon() calls _exit() (not even exit()) in the parent after the fork, the only way to synchronize the pid writing is not to use the daemon() at all and inline d

Re: [systemd-devel] option to wait for pid file to appear

2018-06-07 Thread Lennart Poettering
On Do, 07.06.18 09:50, Igor Bukanov (i...@mir2.org) wrote: > On 18 May 2018 at 19:37, Lennart Poettering wrote: > > On Do, 17.05.18 22:54, Igor Bukanov (i...@mir2.org) wrote: > > Well, no. The protocol is clear, and what we do is pretty close to > > black magic, and still racy in many ways. > > >

Re: [systemd-devel] option to wait for pid file to appear

2018-06-07 Thread Michael Chapman
On Thu, 7 Jun 2018, Igor Bukanov wrote: > On 18 May 2018 at 19:37, Lennart Poettering wrote: > > On Do, 17.05.18 22:54, Igor Bukanov (i...@mir2.org) wrote: > > Well, no. The protocol is clear, and what we do is pretty close to > > black magic, and still racy in many ways. > > > > I mean, broken be

Re: [systemd-devel] option to wait for pid file to appear

2018-06-07 Thread Igor Bukanov
On 18 May 2018 at 19:37, Lennart Poettering wrote: > On Do, 17.05.18 22:54, Igor Bukanov (i...@mir2.org) wrote: > Well, no. The protocol is clear, and what we do is pretty close to > black magic, and still racy in many ways. > > I mean, broken behaviour is still broken behaviour, even if we > nowa

Re: [systemd-devel] option to wait for pid file to appear

2018-05-18 Thread Lennart Poettering
On Do, 17.05.18 22:54, Igor Bukanov (i...@mir2.org) wrote: > On 17 May 2018 at 19:23, Lennart Poettering wrote: > > > So yes, this is a bug in nginx. They really should fix that. And this > > is not only broken when you use systemd, but on sysvinit too, as a > > command like this would likely fa

Re: [systemd-devel] option to wait for pid file to appear

2018-05-18 Thread Ian Pilcher
On 05/17/2018 03:54 PM, Igor Bukanov wrote: Given that systemd deals with this situation in a very reasonable way, nginx must not be alone in doing this. And if this a common way to write such code, perhaps it should not be considered a bug but rather one more peculiarity of application services

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Reindl Harald
Am 17.05.2018 um 22:54 schrieb Igor Bukanov: > On 17 May 2018 at 19:23, Lennart Poettering wrote: > >> So yes, this is a bug in nginx. They really should fix that. And this >> is not only broken when you use systemd, but on sysvinit too, as a >> command like this would likely fail there too: "s

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Igor Bukanov
On 17 May 2018 at 19:23, Lennart Poettering wrote: > So yes, this is a bug in nginx. They really should fix that. And this > is not only broken when you use systemd, but on sysvinit too, as a > command like this would likely fail there too: "service nginx start > service nginx status", as the sta

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Lennart Poettering
On Do, 17.05.18 13:18, Igor Bukanov (i...@mir2.org) wrote: > Notice that there are 2 master processes, the old one with pid 2408 > and the one 2418. Initiate the shutdown of the initial master: nginx can let PID 1 know about the new main PID by sending a MAINPID= sd_notify() message. Or even bet

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Lennart Poettering
On Do, 17.05.18 11:33, Reindl Harald (h.rei...@thelounge.net) wrote: > > 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? > > this is a bug in nginx > > howev

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Lennart Poettering
On Do, 17.05.18 11:25, 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

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Zbigniew Jędrzejewski-Szmek
On Thu, May 17, 2018 at 12:12:10PM +0200, Igor Bukanov wrote: > On 17 May 2018 at 11:58, Mantas Mikulėnas wrote: > > Have you tried without the PIDFile= setting at all? > > As far as I can see that breaks live updates that nginx supports where > it starts a new process and workers and then gracef

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Igor Bukanov
On 17 May 2018 at 11:58, Mantas Mikulėnas wrote: > this would be anyways broken because systemd reads the PIDFile once at > start to dtermine MAINPID and if MAINPID goes away the service fails This is not true as with PIDFile systemd does pick up the new process as a new main without restarting t

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Michael Chapman
On Thu, 17 May 2018, Igor Bukanov wrote: > On 17 May 2018 at 12:07, Michael Chapman wrote: > > It _is_ better for the PID file to be written out before the initial > > process exits, but systemd will handle things correctly even if they > > happen the other way around. Essentially the service won'

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Igor Bukanov
On 17 May 2018 at 12:07, Michael Chapman wrote: > It _is_ better for the PID file to be written out before the initial > process exits, but systemd will handle things correctly even if they > happen the other way around. Essentially the service won't be considered > to have completed activation un

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Michael Chapman
On Thu, 17 May 2018, Igor Bukanov 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 > >

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Reindl Harald
Am 17.05.2018 um 12:12 schrieb Igor Bukanov: > On 17 May 2018 at 11:58, Mantas Mikulėnas wrote: >> Have you tried without the PIDFile= setting at all? > > As far as I can see that breaks live updates that nginx supports where > it starts a new process and workers and then gracefully terminates

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Igor Bukanov
On 17 May 2018 at 11:58, Mantas Mikulėnas wrote: > Have you tried without the PIDFile= setting at all? As far as I can see that breaks live updates that nginx supports where it starts a new process and workers and then gracefully terminates the old main. Regards, Igor ___

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Mantas Mikulėnas
On Thu, May 17, 2018, 12:26 Igor Bukanov 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 director

Re: [systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Reindl Harald
Am 17.05.2018 um 11:25 schrieb Igor Bukanov: > 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 > > Aft

[systemd-devel] option to wait for pid file to appear

2018-05-17 Thread Igor Bukanov
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 i