]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MAJOR: mworker: exits the master on failure
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 24 Nov 2017 21:02:34 +0000 (22:02 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 24 Nov 2017 21:48:27 +0000 (22:48 +0100)
This patch changes the behavior of the master during the exit of a
worker.

When a worker exits with an error code, for example in the case of a
segfault, all workers are now killed and the master leaves.

If you don't want this behavior you can use the option
"master-worker no-exit-on-failure".

doc/configuration.txt
include/types/global.h
src/cfgparse.c
src/haproxy.c

index ea326d19a7e1d6d61781eb561d1424246d2a9e73..6fb239aa1de5d5a625ffa7c76543756ec5d27fa3 100644 (file)
@@ -869,19 +869,20 @@ lua-load <file>
   This global directive loads and executes a Lua file. This directive can be
   used multiple times.
 
-master-worker [exit-on-failure]
+master-worker [no-exit-on-failure]
   Master-worker mode. It is equivalent to the command line "-W" argument.
   This mode will launch a "master" which will monitor the "workers". Using
   this mode, you can reload HAProxy directly by sending a SIGUSR2 signal to
   the master.  The master-worker mode is compatible either with the foreground
   or daemon mode. It is recommended to use this mode with multiprocess and
   systemd.
-  The "exit-on-failure" option allows the master to kill every workers and
-  exit when one of the current workers died. It is convenient to combine this
-  option with Restart=on-failure in a systemd unit file in order to relaunch
-  the whole process.
+  By default, if a worker exits with a bad return code, in the case of a
+  segfault for example, all workers will be killed, and the master will leave.
+  It is convenient to combine this behavior with Restart=on-failure in a
+  systemd unit file in order to relaunch the whole process. If you don't want
+  this behavior, you must use the keyword "no-exit-on-failure".
 
-  See alors "-W" in the management guide.
+  See also "-W" in the management guide.
 
 nbproc <number>
   Creates <number> processes when going daemon. This requires the "daemon"
index 0f50d4571a146e7113d1b09d175e56a417072594..a3d1e96202641d83ad90431b497e6adfd08f83e9 100644 (file)
@@ -65,7 +65,7 @@
 #define GTUNE_RESOLVE_DONTFAIL   (1<<7)
 
 #define GTUNE_SOCKET_TRANSFER   (1<<8)
-#define GTUNE_EXIT_ONFAILURE     (1<<9)
+#define GTUNE_NOEXIT_ONFAILURE   (1<<9)
 #define GTUNE_USE_SYSTEMD        (1<<10)
 
 /* Access level for a stats socket */
index f70eafb5db9c66b063fc93dafc0c88813255cf1f..e7e32cf9d2e414441b5371184f5efa0ed2b04e21 100644 (file)
@@ -716,8 +716,8 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                if (alertif_too_many_args(1, file, linenum, args, &err_code))
                        goto out;
                if (*args[1]) {
-                       if (!strcmp(args[1], "exit-on-failure")) {
-                               global.tune.options |= GTUNE_EXIT_ONFAILURE;
+                       if (!strcmp(args[1], "no-exit-on-failure")) {
+                               global.tune.options |= GTUNE_NOEXIT_ONFAILURE;
                        } else {
                                ha_alert("parsing [%s:%d] : '%s' only supports 'exit-on-failure' option.\n", file, linenum, args[0]);
                                err_code |= ERR_ALERT | ERR_FATAL;
index faa46e076e69b333534171640a844a6e1480b72d..891a021d945c052be3fc05550b95833f8fb16f4b 100644 (file)
@@ -759,7 +759,7 @@ restart_wait:
                        if (current_child(exitpid)) {
                                ha_alert("Current worker %d left with exit code %d\n", exitpid, status);
                                if (status != 0 && status != 130 && status != 143
-                                   && global.tune.options & GTUNE_EXIT_ONFAILURE) {
+                                   && !(global.tune.options & GTUNE_NOEXIT_ONFAILURE)) {
                                        ha_alert("exit-on-failure: killing every workers with SIGTERM\n");
                                        mworker_kill(SIGTERM);
                                }