There is a known (harmless?) race condition when systemd starts nginx on 1-CPU systems. Suggested fixes can be found: https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1581864 https://www.cloudinsidr.com/content/heres-fix-nginx-error-failed-read-pid-file-linux/ Reproducible: Always
The linked bug report contains a comment that > ExecStopPost=/bin/rm -f /run/nginx.pid would also help. I.e. the problem seems to be a previous pidfile?! Because we do > stop_post() { > rm -f ${pidfile} > } already in runscript, the ExecStopPost would be an acceptable solution for me. Can you confirm that this will solve the problem?
(In reply to Thomas Deutschmann from comment #1) > The linked bug report contains a comment that > > > ExecStopPost=/bin/rm -f /run/nginx.pid > would also help. I.e. the problem seems to be a previous pidfile?! No, the problem is not a previous pidfile. It is removed correctly. As I said and is described in the linked ubuntu bug, the issue is a race condition. Furthermore, the linked ubuntu bug, comment 7 <https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1581864/comments/7> says: > 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 In the service file, there is, currently, [Service] Type=forking PIDFile=/run/nginx.pid ExecStartPre=/usr/sbin/nginx -t ExecStart=/usr/sbin/nginx ExecReload=/bin/kill -HUP $MAINPID ExecStop=/bin/kill -QUIT $MAINPID So I guess that what is meant, is to change this to [Service] Type=forking ExecStartPre=/usr/sbin/nginx -t ExecStart=/usr/sbin/nginx ExecReload=/bin/kill -HUP $MAINPID ExecStop=/bin/kill -QUIT $MAINPID ExecStopPost=/bin/rm -f /run/nginx.pid But I have no idea how this impacts things. (I am neither an expert in systemd nor in nginx.) > Because we do > > > stop_post() { > > rm -f ${pidfile} > > } > already in runscript, the ExecStopPost would be an acceptable solution for > me. > > Can you confirm that this will solve the problem? Not at this point. And if it would for me, it could create new problems for others. What is the reason for not using the patch <https://launchpadlibrarian.net/426320897/nginx-fix-pidfile.8.patch>? (I've informed whether it is supposed to go upstream.)
At the moment I can't tell if the patch is solving the problem the correct way. And I don't feel comfortable in general adding a patch without any comment from upstream regarding the issue itself.
(In reply to Thomas Deutschmann from comment #3) > At the moment I can't tell if the patch is solving the problem the correct > way. And I don't feel comfortable in general adding a patch without any > comment from upstream regarding the issue itself. I understand. I have submitted an upstream ticket: https://trac.nginx.org/nginx/ticket/1952#ticket. Let's wait to see what they say.
(In reply to Erik Quaeghebeur from comment #4) > I have submitted an upstream ticket: > https://trac.nginx.org/nginx/ticket/1952#ticket. Let's wait to see what they > say. They decide it's a WONTFIX and that the Ubuntu patch is not the good approach: https://trac.nginx.org/nginx/ticket/1897 Closing as RESOLVED WONTFIX.
Is it really just a message or is it causing some problems like systemctl will report degraded state? I think we can add > ExecStartPost=/bin/sleep 0.1 as workaround to systemd service file until a systemd version with > Type=pid-file landed in Gentoo.
(In reply to Thomas Deutschmann from comment #6) > Is it really just a message or is it causing some problems like systemctl > will report degraded state? No problems apparent. Does not cause a degraded state report. > I think we can add > > > ExecStartPost=/bin/sleep 0.1 > > as workaround to systemd service file until a systemd version with > > > Type=pid-file > landed in Gentoo. That you can do. I tested it, and it seems to remove the issue for me.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ebd358e0aaa62b455d1eb318f509bb1804fe3285 commit ebd358e0aaa62b455d1eb318f509bb1804fe3285 Author: Thomas Deutschmann <whissi@gentoo.org> AuthorDate: 2020-04-11 20:45:27 +0000 Commit: Thomas Deutschmann <whissi@gentoo.org> CommitDate: 2020-04-11 21:10:37 +0000 www-servers/nginx: add workaround for race-condition on systemd Closes: https://bugs.gentoo.org/716700 Package-Manager: Portage-2.3.98, Repoman-2.3.22 Signed-off-by: Thomas Deutschmann <whissi@gentoo.org> www-servers/nginx/files/nginx.service-r1 | 1 + 1 file changed, 1 insertion(+)