Welcome! Log In Create A New Profile

Advanced

[PATCH] Add configuration option for the timeout for childs handling SIGTERM.

March 23, 2015 03:42PM
Hi,

For testing quick termination during high loads, while running with
valgrind, it might be useful to be able to extend the amount of time nginx
allows child processes to wrap up before sending SIGKILL.
For ngx_pagespeed, the current hard-coded default of 1 second seems to be
just short of what we need to be able to reliably test just this scenario,
so I've made a patch so we can run with different values for with and
without valgrind.
Would the following patch be acceptable?

Kind regards,

Otto


# HG changeset patch
# User Otto van der Schaaf <oschaaf@we-amp.com>
# Date 1427138606 -3600
# Mon Mar 23 20:23:26 2015 +0100
# Node ID 92c9d38d7677b5f646112cde94dc40d834d5ef74
# Parent b6eb6ec4fbd9807d75de071fffb000c4f3a5c57d
Add configuration option for the timeout for childs handling SIGTERM.

Adds a configuration option (child_terminate_timeout) to allow tweaking
the amount of time nginx allows child processes before sending SIGKILL.
This is helpful for testing termination with higher loads under valgrind,
as the hard-coded default (1000 ms) might not always be enough.

diff -r b6eb6ec4fbd9 -r 92c9d38d7677 src/core/nginx.c
--- a/src/core/nginx.c Mon Mar 23 21:09:19 2015 +0300
+++ b/src/core/nginx.c Mon Mar 23 20:23:26 2015 +0100
@@ -125,6 +125,13 @@
offsetof(ngx_core_conf_t, rlimit_sigpending),
NULL },

+ { ngx_string("child_terminate_timeout"),
+ NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_msec_slot,
+ 0,
+ offsetof(ngx_core_conf_t, child_terminate_timeout),
+ NULL },
+
{ ngx_string("working_directory"),
NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
@@ -955,6 +962,7 @@
ccf->rlimit_nofile = NGX_CONF_UNSET;
ccf->rlimit_core = NGX_CONF_UNSET;
ccf->rlimit_sigpending = NGX_CONF_UNSET;
+ ccf->child_terminate_timeout = NGX_CONF_UNSET_MSEC;

ccf->user = (ngx_uid_t) NGX_CONF_UNSET_UINT;
ccf->group = (ngx_gid_t) NGX_CONF_UNSET_UINT;
@@ -985,6 +993,7 @@

ngx_conf_init_value(ccf->worker_processes, 1);
ngx_conf_init_value(ccf->debug_points, 0);
+ ngx_conf_init_value(ccf->child_terminate_timeout, 1000);

#if (NGX_HAVE_CPU_AFFINITY)

diff -r b6eb6ec4fbd9 -r 92c9d38d7677 src/core/ngx_cycle.h
--- a/src/core/ngx_cycle.h Mon Mar 23 21:09:19 2015 +0300
+++ b/src/core/ngx_cycle.h Mon Mar 23 20:23:26 2015 +0100
@@ -85,6 +85,7 @@
ngx_int_t rlimit_sigpending;
off_t rlimit_core;

+ ngx_msec_t child_terminate_timeout;
int priority;

ngx_uint_t cpu_affinity_n;
diff -r b6eb6ec4fbd9 -r 92c9d38d7677 src/os/unix/ngx_process_cycle.c
--- a/src/os/unix/ngx_process_cycle.c Mon Mar 23 21:09:19 2015 +0300
+++ b/src/os/unix/ngx_process_cycle.c Mon Mar 23 20:23:26 2015 +0100
@@ -189,7 +189,7 @@

sigio = ccf->worker_processes + 2 /* cache processes */;

- if (delay > 1000) {
+ if (delay > ccf->child_terminate_timeout) {
ngx_signal_worker_processes(cycle, SIGKILL);
} else {
ngx_signal_worker_processes(cycle,
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Add configuration option for the timeout for childs handling SIGTERM.

oschaaf 575 March 23, 2015 03:42PM

Re: [PATCH] Add configuration option for the timeout for childs handling SIGTERM.

Maxim Dounin 250 March 23, 2015 06:20PM

Re: [PATCH] Add configuration option for the timeout for childs handling SIGTERM.

oschaaf 288 March 23, 2015 06:36PM

Re: [PATCH] Add configuration option for the timeout for childs handling SIGTERM.

Maxim Dounin 258 March 24, 2015 01:04PM

Re: [PATCH] Add configuration option for the timeout for childs handling SIGTERM.

oschaaf 319 March 25, 2015 09:44AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 263
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready