<div dir="ltr"><div>exporting patch:</div><div># HG changeset patch</div><div># User RocFang <<a href="mailto:fangpeng1986@gmail.com">fangpeng1986@gmail.com</a>></div><div># Date 1497882783 0</div><div># Node ID 8b9e416ef7f9f8e7f96eaa53b479062683464481</div><div># Parent  a39bc74873faf9e5bea616561b43f6ecc55229f9</div><div>Introduced reload_delay.</div><div><br></div><div>Previously, the master process will sleep 100ms before sending a</div><div>SHUTDOWN signal to old worker processes when reload. This patch</div><div>make the sleep time configurable, because in some scenarios, the</div><div>new workers may spend more than 100ms to get ready. For example,</div><div>the init_prcess hook of some 3rd modules may be time-consuming.</div><div><br></div><div>diff -r a39bc74873fa -r 8b9e416ef7f9 src/core/nginx.c</div><div>--- a/src/core/nginx.c<span class="gmail-Apple-tab-span" style="white-space:pre">        </span>Mon Jun 19 14:25:42 2017 +0300</div><div>+++ b/src/core/nginx.c<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>Mon Jun 19 14:33:03 2017 +0000</div><div>@@ -152,6 +152,13 @@</div><div>       0,</div><div>       NULL },</div><div> </div><div>+    { ngx_string("reload_delay"),</div><div>+      NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,</div><div>+      ngx_conf_set_msec_slot,</div><div>+      0,</div><div>+      offsetof(ngx_core_conf_t, reload_delay),</div><div>+      NULL },</div><div>+</div><div>       ngx_null_command</div><div> };</div><div> </div><div>@@ -1022,6 +1029,7 @@</div><div>     ccf->master = NGX_CONF_UNSET;</div><div>     ccf->timer_resolution = NGX_CONF_UNSET_MSEC;</div><div>     ccf->shutdown_timeout = NGX_CONF_UNSET_MSEC;</div><div>+    ccf->reload_delay = NGX_CONF_UNSET_MSEC;</div><div> </div><div>     ccf->worker_processes = NGX_CONF_UNSET;</div><div>     ccf->debug_points = NGX_CONF_UNSET;</div><div>@@ -1051,6 +1059,7 @@</div><div>     ngx_conf_init_value(ccf->master, 1);</div><div>     ngx_conf_init_msec_value(ccf->timer_resolution, 0);</div><div>     ngx_conf_init_msec_value(ccf->shutdown_timeout, 0);</div><div>+    ngx_conf_init_msec_value(ccf->reload_delay, 100);</div><div> </div><div>     ngx_conf_init_value(ccf->worker_processes, 1);</div><div>     ngx_conf_init_value(ccf->debug_points, 0);</div><div>diff -r a39bc74873fa -r 8b9e416ef7f9 src/core/ngx_cycle.h</div><div>--- a/src/core/ngx_cycle.h<span class="gmail-Apple-tab-span" style="white-space:pre">       </span>Mon Jun 19 14:25:42 2017 +0300</div><div>+++ b/src/core/ngx_cycle.h<span class="gmail-Apple-tab-span" style="white-space:pre">       </span>Mon Jun 19 14:33:03 2017 +0000</div><div>@@ -89,6 +89,7 @@</div><div> </div><div>     ngx_msec_t                timer_resolution;</div><div>     ngx_msec_t                shutdown_timeout;</div><div>+    ngx_msec_t                reload_delay;</div><div> </div><div>     ngx_int_t                 worker_processes;</div><div>     ngx_int_t                 debug_points;</div><div>diff -r a39bc74873fa -r 8b9e416ef7f9 src/os/unix/ngx_process_cycle.c</div><div>--- a/src/os/unix/ngx_process_cycle.c<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>Mon Jun 19 14:25:42 2017 +0300</div><div>+++ b/src/os/unix/ngx_process_cycle.c<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>Mon Jun 19 14:33:03 2017 +0000</div><div>@@ -245,7 +245,7 @@</div><div>             ngx_start_cache_manager_processes(cycle, 1);</div><div> </div><div>             /* allow new processes to start */</div><div>-            ngx_msleep(100);</div><div>+            ngx_msleep(ccf->reload_delay);</div><div> </div><div>             live = 1;</div><div>             ngx_signal_worker_processes(cycle,</div><div><br></div></div>