#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
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")) {
/* 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);