summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Corbacho <diana@rabbitmq.com>2017-05-03 12:29:52 +0100
committerDiana Corbacho <diana@rabbitmq.com>2017-05-03 12:29:52 +0100
commit6b13679b725ec12aee2569f07ac15618eb99a34b (patch)
treef29e1d7e3d66cbb80c6a3c3c92a81e3506866ab3
parentf580a7652166a4836b0fbbe881c3f6e6a5b49f36 (diff)
parent8cedd3f53a14e45ccc68868bbc6401bb321ee50f (diff)
downloadrabbitmq-server-git-6b13679b725ec12aee2569f07ac15618eb99a34b.tar.gz
Merge remote-tracking branch 'origin/stable'
-rwxr-xr-xscripts/rabbitmq-server41
-rw-r--r--src/rabbit_disk_monitor.erl4
2 files changed, 32 insertions, 13 deletions
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server
index 41d1a81332..a318b55d75 100755
--- a/scripts/rabbitmq-server
+++ b/scripts/rabbitmq-server
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/sh
## The contents of this file are subject to the Mozilla Public License
## Version 1.1 (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License
@@ -12,9 +12,11 @@
## The Original Code is RabbitMQ.
##
## The Initial Developer of the Original Code is GoPivotal, Inc.
-## Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved.
+## Copyright (c) 2007-2017 Pivotal Software, Inc. All rights reserved.
##
+set -e
+
# Get default settings with user overrides for (RABBITMQ_)<var_name>
# Non-empty defaults should be set in rabbitmq-env
. `dirname $0`/rabbitmq-env
@@ -278,21 +280,38 @@ else
# The Erlang VM should ignore SIGINT.
RABBITMQ_SERVER_START_ARGS="${RABBITMQ_SERVER_START_ARGS} ${RABBITMQ_IGNORE_SIGINT_FLAG}"
- # Signal handlers. They all stop RabbitMQ properly (using
- # rabbitmqctl stop). Depending on the signal, this script will exit
- # with a non-zero error code:
+ # Signal handlers. They all stop RabbitMQ properly, using
+ # rabbitmqctl stop. This script will exit with different exit codes:
# SIGHUP SIGTERM SIGTSTP
- # They are considered a normal process termination, so the script
- # exits with 0.
+ # Exits 0 since this is considered a normal process termination.
# SIGINT
- # They are considered an abnormal process termination, the script
- # exits with the job exit code.
+ # Exits 128 + $signal_number where $signal_number is 2 for SIGINT (see
+ # http://pubs.opengroup.org/onlinepubs/009695399/utilities/kill.html).
+ # This is considered an abnormal process termination. Normally, we
+ # 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 explicitely restate the exit code.
trap "stop_rabbitmq_server; exit 0" HUP TERM TSTP
- trap "stop_rabbitmq_server" INT
+ trap "stop_rabbitmq_server; exit 130" INT
start_rabbitmq_server "$@" &
+ rabbitmq_server_pid=$!
# Block until RabbitMQ exits or a signal is caught.
# Waits for last command (which is start_rabbitmq_server)
- wait $!
+ #
+ # The "|| true" is here to work around an issue with Dash. Normally
+ # in a Bourne shell, if `wait` is interrupted by a signal, the
+ # signal handlers defined above are executed and the script
+ # terminates with the exit code of `wait` (unless the signal handler
+ # overrides that).
+ # In the case of Dash, it looks like `set -e` (set at the beginning
+ # of this script) gets precedence over signal handling. Therefore,
+ # when `wait` is interrupted, its exit code is non-zero and because
+ # of `set -e`, the script terminates immediately without running the
+ # signal handler. To work around this issue, we use "|| true" to
+ # force that statement to succeed and the signal handler to properly
+ # execute. Because the statement below has an exit code of 0, the
+ # signal handler has to restate the expected exit code.
+ wait $rabbitmq_server_pid || true
fi
diff --git a/src/rabbit_disk_monitor.erl b/src/rabbit_disk_monitor.erl
index 629228a1be..868fc1a4aa 100644
--- a/src/rabbit_disk_monitor.erl
+++ b/src/rabbit_disk_monitor.erl
@@ -75,7 +75,7 @@
%%----------------------------------------------------------------------------
--type disk_free_limit() :: (integer() | string() | {'mem_relative', float()}).
+-type disk_free_limit() :: (integer() | string() | {'mem_relative', float() | integer()}).
-spec start_link(disk_free_limit()) -> rabbit_types:ok_pid_or_error().
-spec get_disk_free_limit() -> integer().
-spec set_disk_free_limit(disk_free_limit()) -> 'ok'.
@@ -237,7 +237,7 @@ parse_free_win32(CommandResult) ->
list_to_integer(lists:reverse(Free)).
interpret_limit({mem_relative, Relative})
- when is_float(Relative) ->
+ when is_number(Relative) ->
round(Relative * vm_memory_monitor:get_total_memory());
interpret_limit(Absolute) ->
case rabbit_resource_monitor_misc:parse_information_unit(Absolute) of