You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.8 KiB

  1. From 6bb7bf7949dd019403b65f400c4b3d0d8589327b Mon Sep 17 00:00:00 2001
  2. From: Matt Robenolt <matt@ydekproductions.com>
  3. Date: Thu, 11 Sep 2014 05:19:30 +0000
  4. Subject: [PATCH 04/13] MINOR: Also accept SIGHUP/SIGTERM in systemd-wrapper
  5. My proposal is to let haproxy-systemd-wrapper also accept normal
  6. SIGHUP/SIGTERM signals to play nicely with other process managers
  7. besides just systemd. In my use case, this will be for using with
  8. runit which has to ability to change the signal used for a
  9. "reload" or "stop" command. It also might be worth renaming this
  10. bin to just haproxy-wrapper or something of that sort to separate
  11. itself away from systemd. But that's a different discussion. :)
  12. (cherry picked from commit c54bdd2a118161b4dc36963b4201edfa7341dadb)
  13. ---
  14. src/haproxy-systemd-wrapper.c | 6 ++++--
  15. 1 file changed, 4 insertions(+), 2 deletions(-)
  16. diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
  17. index 90a94ce..cc8baa8 100644
  18. --- a/src/haproxy-systemd-wrapper.c
  19. +++ b/src/haproxy-systemd-wrapper.c
  20. @@ -158,7 +158,9 @@ int main(int argc, char **argv)
  21. memset(&sa, 0, sizeof(struct sigaction));
  22. sa.sa_handler = &signal_handler;
  23. sigaction(SIGUSR2, &sa, NULL);
  24. + sigaction(SIGHUP, &sa, NULL);
  25. sigaction(SIGINT, &sa, NULL);
  26. + sigaction(SIGTERM, &sa, NULL);
  27. if (getenv(REEXEC_FLAG) != NULL) {
  28. /* We are being re-executed: restart HAProxy gracefully */
  29. @@ -180,11 +182,11 @@ int main(int argc, char **argv)
  30. status = -1;
  31. while (-1 != wait(&status) || errno == EINTR) {
  32. - if (caught_signal == SIGUSR2) {
  33. + if (caught_signal == SIGUSR2 || caught_signal == SIGHUP) {
  34. caught_signal = 0;
  35. do_restart();
  36. }
  37. - else if (caught_signal == SIGINT) {
  38. + else if (caught_signal == SIGINT || caught_signal == SIGTERM) {
  39. caught_signal = 0;
  40. do_shutdown();
  41. }
  42. --
  43. 1.8.5.5