mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-11 03:31:36 +00:00
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.
This commit is contained in:
parent
85b0bd9e54
commit
69f9b3bfa4
@ -63,6 +63,7 @@
|
||||
#define GTUNE_RESOLVE_DONTFAIL (1<<7)
|
||||
|
||||
#define GTUNE_SOCKET_TRANSFER (1<<8)
|
||||
#define GTUNE_EXIT_ONFAILURE (1<<9)
|
||||
|
||||
/* Access level for a stats socket */
|
||||
#define ACCESS_LVL_NONE 0
|
||||
|
@ -625,8 +625,17 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
global.mode |= MODE_DAEMON;
|
||||
}
|
||||
else if (!strcmp(args[0], "master-worker")) {
|
||||
if (alertif_too_many_args(0, file, linenum, args, &err_code))
|
||||
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;
|
||||
} else {
|
||||
Alert("parsing [%s:%d] : '%s' only supports 'exit-on-failure' option.\n", file, linenum, args[0]);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
global.mode |= MODE_MWORKER;
|
||||
}
|
||||
else if (!strcmp(args[0], "debug")) {
|
||||
|
@ -671,6 +671,11 @@ static void mworker_wait()
|
||||
/* 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);
|
||||
|
Loading…
Reference in New Issue
Block a user