MEDIUM: global: add a 'hard-stop-after' option to cap the soft-stop time
When SIGUSR1 is received, haproxy enters in soft-stop and quits when no
connection remains.
It can happen that the instance remains alive for a long time, depending
on timeouts and traffic. This option ensures that soft-stop won't run
for too long.
Example:
global
hard-stop-after 30s # Once in soft-stop, the instance will remain
# alive for at most 30 seconds.
diff --git a/src/haproxy.c b/src/haproxy.c
index 559b481..4f30d72 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -117,6 +117,7 @@
/* global options */
struct global global = {
+ .hard_stop_after = TICK_ETERNITY,
.nbproc = 1,
.req_count = 0,
.logsrvs = LIST_HEAD_INIT(global.logsrvs),
@@ -157,6 +158,7 @@
/*********************************************************************/
int stopping; /* non zero means stopping in progress */
+int killed; /* non zero means a hard-stop is triggered */
int jobs = 0; /* number of active jobs (conns, listeners, active tasks, ...) */
/* Here we store informations about the pids of the processes we may pause
@@ -593,6 +595,7 @@
*/
totalconn = actconn = maxfd = listeners = stopping = 0;
+ killed = 0;
#ifdef HAPROXY_MEMMAX
@@ -1225,7 +1228,7 @@
}
}
-static void deinit(void)
+void deinit(void)
{
struct proxy *p = proxy, *p0;
struct cap_hdr *h,*h_next;