mirror of
https://github.com/openresty/openresty
synced 2024-11-14 08:45:50 +01:00
54 lines
1.8 KiB
C
54 lines
1.8 KiB
C
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
|
|
index 1710ea81..b379da9c 100644
|
|
--- a/src/os/unix/ngx_process_cycle.c
|
|
+++ b/src/os/unix/ngx_process_cycle.c
|
|
@@ -304,11 +304,26 @@ ngx_single_process_cycle(ngx_cycle_t *cycle)
|
|
}
|
|
|
|
for ( ;; ) {
|
|
+ if (ngx_exiting) {
|
|
+ if (ngx_event_no_timers_left() == NGX_OK) {
|
|
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
|
|
+
|
|
+ for (i = 0; cycle->modules[i]; i++) {
|
|
+ if (cycle->modules[i]->exit_process) {
|
|
+ cycle->modules[i]->exit_process(cycle);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ ngx_master_process_exit(cycle);
|
|
+ }
|
|
+ }
|
|
+
|
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
|
|
|
|
ngx_process_events_and_timers(cycle);
|
|
|
|
- if (ngx_terminate || ngx_quit) {
|
|
+ if (ngx_terminate) {
|
|
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
|
|
|
|
for (i = 0; cycle->modules[i]; i++) {
|
|
if (cycle->modules[i]->exit_process) {
|
|
@@ -319,6 +334,20 @@ ngx_single_process_cycle(ngx_cycle_t *cycle)
|
|
ngx_master_process_exit(cycle);
|
|
}
|
|
|
|
+ if (ngx_quit) {
|
|
+ ngx_quit = 0;
|
|
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
|
|
+ "gracefully shutting down");
|
|
+ ngx_setproctitle("process is shutting down");
|
|
+
|
|
+ if (!ngx_exiting) {
|
|
+ ngx_exiting = 1;
|
|
+ ngx_set_shutdown_timer(cycle);
|
|
+ ngx_close_listening_sockets(cycle);
|
|
+ ngx_close_idle_connections(cycle);
|
|
+ }
|
|
+ }
|
|
+
|
|
if (ngx_reconfigure) {
|
|
ngx_reconfigure = 0;
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reconfiguring");
|