Hi,

We are also affected, and I've looked into the source. In main(), the
ngx_create_pidfile() gets called right after the ngx_daemon() function.
ngx_daemon of course forks, and the parent process exits immediately
with exit(0). This is a pure race condition between nginx and systemd.

This is not a problem (other than the scary log), because the PIDFile
option is not needed for determining the main PID of nginx (systemd can
correctly "guess" the main pid), it's only for removing the file when
the service exits.

As far as I can tell, this daemonization is not needed for the systemd
service use-case. The service should be Type=simple, and 'daemon off'.
The standard file handles get redirected by systemd anyway, and non-stop
upgrade cannot be used in this case either. (See:
http://nginx.org/en/docs/faq/daemon_master_process_off.html )

If this is too much of a change, another workaround is removing the PIDFile 
option, and adding the line:
ExecStopPost=/bin/rm -f /run/nginx.pid

Regards,
Alex

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1581864

Title:
  nginx.service: Failed to read PID from file /run/nginx.pid: Invalid
  argument

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1581864/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to