[PATCH] Workaround for systemd error messages about nginx pid file.

Gena Makhomed gmm at csdoc.com
Wed Nov 29 10:33:28 UTC 2017


# HG changeset patch
# User Gena Makhomed <gmm at csdoc.com>
# Date 1511951401 -7200
#      Wed Nov 29 12:30:01 2017 +0200
# Node ID b529ea784244e13d8a5e58a12c8b639351652057
# Parent  fc0d06224edac2c7cfbfd9a4def478f285d9957b
Workaround for systemd error messages about nginx pid file.

Race condition exists between nginx writing and systemd reading pid file.
Sometimes systemd can produce error messages about nginx pid file:

systemd: Failed to read PID from file /var/run/nginx.pid: Invalid argument
systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

This patch add small delay before nginx original process exit
to eliminate race condition between nginx and systemd.

diff -r fc0d06224eda -r b529ea784244 src/os/unix/ngx_daemon.c
--- a/src/os/unix/ngx_daemon.c  Tue Nov 28 13:09:54 2017 +0300
+++ b/src/os/unix/ngx_daemon.c  Wed Nov 29 12:30:01 2017 +0200
@@ -23,6 +23,7 @@
          break;

      default:
+        ngx_msleep(100);
          exit(0);
      }




More information about the nginx-devel mailing list