MINOR: Also accept SIGHUP/SIGTERM in systemd-wrapper

My proposal is to let haproxy-systemd-wrapper also accept normal
SIGHUP/SIGTERM signals to play nicely with other process managers
besides just systemd. In my use case, this will be for using with
runit which has to ability to change the signal used for a
"reload" or "stop" command. It also might be worth renaming this
bin to just haproxy-wrapper or something of that sort to separate
itself away from systemd. But that's a different discussion. :)
This commit is contained in:
Matt Robenolt 2014-09-11 05:19:30 +00:00 committed by Willy Tarreau
parent 08afdcb47b
commit c54bdd2a11

View File

@ -158,7 +158,9 @@ int main(int argc, char **argv)
memset(&sa, 0, sizeof(struct sigaction)); memset(&sa, 0, sizeof(struct sigaction));
sa.sa_handler = &signal_handler; sa.sa_handler = &signal_handler;
sigaction(SIGUSR2, &sa, NULL); sigaction(SIGUSR2, &sa, NULL);
sigaction(SIGHUP, &sa, NULL);
sigaction(SIGINT, &sa, NULL); sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
if (getenv(REEXEC_FLAG) != NULL) { if (getenv(REEXEC_FLAG) != NULL) {
/* We are being re-executed: restart HAProxy gracefully */ /* We are being re-executed: restart HAProxy gracefully */
@ -180,11 +182,11 @@ int main(int argc, char **argv)
status = -1; status = -1;
while (-1 != wait(&status) || errno == EINTR) { while (-1 != wait(&status) || errno == EINTR) {
if (caught_signal == SIGUSR2) { if (caught_signal == SIGUSR2 || caught_signal == SIGHUP) {
caught_signal = 0; caught_signal = 0;
do_restart(); do_restart();
} }
else if (caught_signal == SIGINT) { else if (caught_signal == SIGINT || caught_signal == SIGTERM) {
caught_signal = 0; caught_signal = 0;
do_shutdown(); do_shutdown();
} }