MINOR: mworker: displays more information when leaving

When a worker is leaving, we display the relative PID and the result of
the strsignal() function if it was killed by a signal.
This commit is contained in:
William Lallemand 2018-11-06 17:37:13 +01:00 committed by Willy Tarreau
parent 550db6d188
commit 18e52a8834

View File

@ -815,32 +815,33 @@ restart_wait:
LIST_DEL(&child->list); LIST_DEL(&child->list);
close(child->ipc_fd[0]); close(child->ipc_fd[0]);
free(child);
break; break;
} }
if (!children) { if (!children) {
ha_warning("Worker %d exited with code %d\n", exitpid, status); ha_warning("Worker %d exited with code %d (%s)\n", exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
} else { } else {
/* check if exited child was in the current children list */ /* check if exited child was in the current children list */
if (current_child(exitpid)) { if (current_child(exitpid)) {
ha_alert("Current worker %d exited with code %d\n", exitpid, status); ha_alert("Current worker #%d (%d) exited with code %d (%s)\n", child->relative_pid, exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
if (status != 0 && status != 130 && status != 143 if (status != 0 && status != 130 && status != 143
&& !(global.tune.options & GTUNE_NOEXIT_ONFAILURE)) { && !(global.tune.options & GTUNE_NOEXIT_ONFAILURE)) {
ha_alert("exit-on-failure: killing every workers with SIGTERM\n"); ha_alert("exit-on-failure: killing every workers with SIGTERM\n");
mworker_kill(SIGTERM); mworker_kill(SIGTERM);
} }
} else { } else {
ha_warning("Former worker %d exited with code %d\n", exitpid, status); ha_warning("Former worker #%d (%d) exited with code %d (%s)\n", child->relative_pid, exitpid, status, (status >= 128) ? strsignal(status - 128) : "Exit");
delete_oldpid(exitpid); delete_oldpid(exitpid);
} }
} }
free(child);
/* do it again to check if it was the last worker */ /* do it again to check if it was the last worker */
goto restart_wait; goto restart_wait;
} }
/* Better rely on the system than on a list of process to check if it was the last one */ /* Better rely on the system than on a list of process to check if it was the last one */
else if (exitpid == -1 && errno == ECHILD) { else if (exitpid == -1 && errno == ECHILD) {
ha_warning("All workers exited. Exiting... (%d)\n", status); ha_warning("All workers exited. Exiting... (%d)\n", (exitcode > 0) ? exitcode : status);
atexit_flag = 0; atexit_flag = 0;
exit(status); /* parent must leave using the latest status code known */ exit(status); /* parent must leave using the latest status code known */
} }