[PATCH] add reload_delay directive

Peng Fang fangpeng1986 at gmail.com
Mon Jun 19 15:09:58 UTC 2017


exporting patch:
# HG changeset patch
# User RocFang <fangpeng1986 at gmail.com>
# Date 1497882783 0
# Node ID 8b9e416ef7f9f8e7f96eaa53b479062683464481
# Parent  a39bc74873faf9e5bea616561b43f6ecc55229f9
Introduced reload_delay.

Previously, the master process will sleep 100ms before sending a
SHUTDOWN signal to old worker processes when reload. This patch
make the sleep time configurable, because in some scenarios, the
new workers may spend more than 100ms to get ready. For example,
the init_prcess hook of some 3rd modules may be time-consuming.

diff -r a39bc74873fa -r 8b9e416ef7f9 src/core/nginx.c
--- a/src/core/nginx.c Mon Jun 19 14:25:42 2017 +0300
+++ b/src/core/nginx.c Mon Jun 19 14:33:03 2017 +0000
@@ -152,6 +152,13 @@
       0,
       NULL },

+    { ngx_string("reload_delay"),
+      NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
+      ngx_conf_set_msec_slot,
+      0,
+      offsetof(ngx_core_conf_t, reload_delay),
+      NULL },
+
       ngx_null_command
 };

@@ -1022,6 +1029,7 @@
     ccf->master = NGX_CONF_UNSET;
     ccf->timer_resolution = NGX_CONF_UNSET_MSEC;
     ccf->shutdown_timeout = NGX_CONF_UNSET_MSEC;
+    ccf->reload_delay = NGX_CONF_UNSET_MSEC;

     ccf->worker_processes = NGX_CONF_UNSET;
     ccf->debug_points = NGX_CONF_UNSET;
@@ -1051,6 +1059,7 @@
     ngx_conf_init_value(ccf->master, 1);
     ngx_conf_init_msec_value(ccf->timer_resolution, 0);
     ngx_conf_init_msec_value(ccf->shutdown_timeout, 0);
+    ngx_conf_init_msec_value(ccf->reload_delay, 100);

     ngx_conf_init_value(ccf->worker_processes, 1);
     ngx_conf_init_value(ccf->debug_points, 0);
diff -r a39bc74873fa -r 8b9e416ef7f9 src/core/ngx_cycle.h
--- a/src/core/ngx_cycle.h Mon Jun 19 14:25:42 2017 +0300
+++ b/src/core/ngx_cycle.h Mon Jun 19 14:33:03 2017 +0000
@@ -89,6 +89,7 @@

     ngx_msec_t                timer_resolution;
     ngx_msec_t                shutdown_timeout;
+    ngx_msec_t                reload_delay;

     ngx_int_t                 worker_processes;
     ngx_int_t                 debug_points;
diff -r a39bc74873fa -r 8b9e416ef7f9 src/os/unix/ngx_process_cycle.c
--- a/src/os/unix/ngx_process_cycle.c Mon Jun 19 14:25:42 2017 +0300
+++ b/src/os/unix/ngx_process_cycle.c Mon Jun 19 14:33:03 2017 +0000
@@ -245,7 +245,7 @@
             ngx_start_cache_manager_processes(cycle, 1);

             /* allow new processes to start */
-            ngx_msleep(100);
+            ngx_msleep(ccf->reload_delay);

             live = 1;
             ngx_signal_worker_processes(cycle,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20170619/66fc19b7/attachment.html>


More information about the nginx-devel mailing list