diff options
| author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2020-02-11 09:45:52 +0100 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2020-02-20 17:41:07 +0100 |
| commit | 02aa73c36b720ae713d182ede1b8fc59966fcb41 (patch) | |
| tree | 2fafa0f0e77f4a003885956bbd4e8ebe96e98e77 /scripts/rabbitmq-server | |
| parent | 3aa744ff56946e291e898bb6482248da626ea3a2 (diff) | |
| download | rabbitmq-server-git-02aa73c36b720ae713d182ede1b8fc59966fcb41.tar.gz | |
Only handle SIGHUP and SIGTSTP
Here is a summary of RabbitMQ signal handling:
== SIGTERM ==
After #2180, `rabbit` is a regular Erlang application and
`application:stop(rabbit)` terminates RabbitMQ gracefully. This means
that `init:stop()` shuts the service down properly. Therefore, the
default handling of SIGTERM, which calls `init:stop()`, is correct.
rabbitmq-server(8) already relies on this mechanism.
This commit restores the default signal handler which already does the
right thing. No need to do it ourselves.
== SIGHUP and SIGTSTP ==
SIHGUP is usually used to reload the configuration without restarting
the service and/or reopen log files after log file rotation. SIGTSTP is
sent when a user types Ctrl+Z to pause a program and get back to the
shell. Both signals have common behavior we can't satisfy currently.
Note that we don't handle SIGCONT which is the one used to resume a
program after SIGTSTP. The system default behavior is already good (the
signal is discarded).
To be consistent with rabbitmq-server(8) signal handling, the signals
are ignored until we can do something about them.
== SIGQUIT ==
This signal is meant to terminate the process immediately and
create a core dump. If possible, temporary files should even be kept
around. The default behavior in Erlang is to call `erlang:halt()` which
is a sane default: we should not stop RabbitMQ gracefully.
This commit restores this behavior.
== SIGUSR1 and SIGUSR2 ==
Erlang uses SIGUSR1 to crash the VM and create an `erl_crash.dump`
file. We already used this in the past to debug RabbitMQ. Again, a sane
default.
This commit restores this behavior.
== Other signals ==
We keep the default behavior of all other signals. None of them are
meant to stop the program gracefully anyway. If a user wants to stop
RabbitMQ, he will already use the common accepted signal for this
purpose (i.e. SIGTERM).
Another change in this commit is the way we setup the signal handler:
* We don't replace the default Erlang signal handler, just add ours.
* We do it very early in rabbitmq_prelaunch. Like other things
configured by this application, we do not uninstall the handler when
the application is stopped.
This reverts:
* commit 6a4d2721d06b8c70a36e29e6c51bbef6608def55
* commit fa607e4a25d6142bb17a90b44ef757572a923c09
Diffstat (limited to 'scripts/rabbitmq-server')
| -rwxr-xr-x | scripts/rabbitmq-server | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server index 5939c845d2..0976c5566a 100755 --- a/scripts/rabbitmq-server +++ b/scripts/rabbitmq-server @@ -141,7 +141,9 @@ else # Signal handlers. They all stop RabbitMQ properly, using # rabbitmqctl stop. This script will exit with different exit codes: - # SIGHUP SIGTERM SIGTSTP + # SIGHUP, SIGTSTP + SIGCONT + # Ignored until we implement a useful behavior. + # SIGTERM # Exits 0 since this is considered a normal process termination. # SIGINT # Exits 128 + $signal_number where $signal_number is 2 for SIGINT (see @@ -150,7 +152,12 @@ else # don't need to specify this exit code because the shell propagates it. # Unfortunately, the signal handler doesn't work as expected in Dash, # thus we need to explicitly restate the exit code. - trap "stop_rabbitmq_server; exit 0" HUP TERM TSTP + # + # The behaviors below should remain consistent with the + # equivalent signal handlers in the Erlang code + # (see apps/rabbitmq_prelaunch/src/rabbit_prelaunch_sighandler.erl). + trap '' HUP TSTP CONT + trap "stop_rabbitmq_server; exit 0" TERM trap "stop_rabbitmq_server; exit 130" INT start_rabbitmq_server "$@" & |
