diff options
| author | Michael Klishin <mklishin@pivotal.io> | 2016-03-17 18:24:33 +0000 |
|---|---|---|
| committer | Michael Klishin <mklishin@pivotal.io> | 2016-03-17 18:24:33 +0000 |
| commit | 32cfe13c5da39c4b8f0a15df87733ab17cdac3fb (patch) | |
| tree | 2d866a2b6c371160459979b27fa14ecee0d89fc9 /scripts/rabbitmq-server | |
| parent | c55d96cf750568ec89b207bf4aa2058a999b71a1 (diff) | |
| parent | e75d8be549a5de161fd8e6f201335ae76c425b6b (diff) | |
| download | rabbitmq-server-git-32cfe13c5da39c4b8f0a15df87733ab17cdac3fb.tar.gz | |
Merge branch 'master' into rabbitmq-server-550
Diffstat (limited to 'scripts/rabbitmq-server')
| -rwxr-xr-x | scripts/rabbitmq-server | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server index 9c7b423982..11285deb47 100755 --- a/scripts/rabbitmq-server +++ b/scripts/rabbitmq-server @@ -47,7 +47,7 @@ case "$(uname -s)" in exit $EX_CANTCREAT fi if ! echo $$ > ${RABBITMQ_PID_FILE}; then - # Bettern diagnostics - otherwise the only report in logs is about failed 'echo' + # Better diagnostics - otherwise the only report in logs is about failed 'echo' # command, but without any other details: neither what script has failed nor what # file output was redirected to. echo "Failed to write pid file: ${RABBITMQ_PID_FILE}" @@ -58,8 +58,13 @@ esac RABBITMQ_EBIN_ROOT="${RABBITMQ_HOME}/ebin" +[ "$NOTIFY_SOCKET" ] && RUNNING_UNDER_SYSTEMD=true + set +e +# NOTIFY_SOCKET is needed here to prevent epmd from impersonating the +# success of our startup sequence to systemd. +NOTIFY_SOCKET= \ RABBITMQ_CONFIG_FILE=$RABBITMQ_CONFIG_FILE \ RABBITMQ_DIST_PORT=$RABBITMQ_DIST_PORT \ ${ERL_DIR}erl -pa "$RABBITMQ_EBIN_ROOT" \ @@ -183,7 +188,20 @@ check_not_empty() { fi } -if [ 'x' = "x$RABBITMQ_ALLOW_INPUT" -a -z "$detached" ]; then +if [ "$RABBITMQ_ALLOW_INPUT" -o "$RUNNING_UNDER_SYSTEMD" -o "$detached" ]; then + # Run erlang VM directly, completely replacing current shell + # process - so the pid file written in the code above will be + # valid (unless detached, which is also handled in the code + # above). + # + # And also this is the correct mode to run the broker under + # systemd - there is no need in a proxy process that converts + # signals to graceful shutdown command, the unit file should already + # contain instructions for graceful shutdown. Also by removing + # this additional process we could simply use value returned by + # `os:getpid/0` for a systemd ready notification. + start_rabbitmq_server "$@" +else # When RabbitMQ runs in the foreground but the Erlang shell is # disabled, we setup signal handlers to stop RabbitMQ properly. This # is at least useful in the case of Docker. @@ -192,7 +210,7 @@ if [ 'x' = "x$RABBITMQ_ALLOW_INPUT" -a -z "$detached" ]; then RABBITMQ_SERVER_START_ARGS="${RABBITMQ_SERVER_START_ARGS} +B i" # Signal handlers. They all stop RabbitMQ properly (using - # rabbitmqctl stop). Depending on the signal, this script will exwit + # rabbitmqctl stop). Depending on the signal, this script will exit # with a non-zero error code: # SIGHUP SIGTERM SIGTSTP # They are considered a normal process termination, so the script @@ -208,6 +226,4 @@ if [ 'x' = "x$RABBITMQ_ALLOW_INPUT" -a -z "$detached" ]; then # Block until RabbitMQ exits or a signal is caught. # Waits for last command (which is start_rabbitmq_server) wait $! -else - start_rabbitmq_server "$@" fi |
