MEDIUM: mworker: exit-on-failure option
This option exits every workers when one of the current workers die.
It allows you to monitor the master process in order to relaunch
everything on a failure.
For example it can be used with systemd and Restart=on-failure in a spec
file.
diff --git a/src/haproxy.c b/src/haproxy.c
index 4e892c0..10ddf16 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -671,6 +671,11 @@
/* check if exited child was in the current children list */
if (current_child(exitpid)) {
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) {
+ Alert("exit-on-failure: killing every workers with SIGTERM\n");
+ mworker_kill(SIGTERM);
+ }
} else {
Warning("Former worker %d left with exit code %d\n", exitpid, status);
delete_oldpid(exitpid);