summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Mazzoli <francesco@rabbitmq.com>2012-09-05 11:36:31 +0100
committerFrancesco Mazzoli <francesco@rabbitmq.com>2012-09-05 11:36:31 +0100
commit881a6f6e1e78f9c9eb40769959fe63c120d8da8b (patch)
tree8e8bedc82f57c61fb22931cb59537f5050ca342e
parent1c17447900a4531fa246700b3611713917dbeff8 (diff)
downloadrabbitmq-server-git-881a6f6e1e78f9c9eb40769959fe63c120d8da8b.tar.gz
don't record pid when using -detached
-rw-r--r--docs/rabbitmq-server.1.xml5
-rwxr-xr-xscripts/rabbitmq-server15
2 files changed, 15 insertions, 5 deletions
diff --git a/docs/rabbitmq-server.1.xml b/docs/rabbitmq-server.1.xml
index 620b1dd388..6003271a10 100644
--- a/docs/rabbitmq-server.1.xml
+++ b/docs/rabbitmq-server.1.xml
@@ -110,8 +110,9 @@ Defaults to 5672.
<listitem>
<para>
Start the server process in the background. Note that this will
- cause the wrong pid to be recorded in the pid file, since the pid
- of the shell that launches the detached process is captured.
+ cause the pid not to be written to the pid file, since the shell
+ will start a detached process and thus the wrong one would be
+ recorded.
</para>
<para role="example-prefix">For example:</para>
<screen role="example">rabbitmq-server -detached</screen>
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server
index 34915b3d7b..1ab3c7222d 100755
--- a/scripts/rabbitmq-server
+++ b/scripts/rabbitmq-server
@@ -65,9 +65,18 @@ case "$(uname -s)" in
CYGWIN*) # we make no attempt to record the cygwin pid; rabbitmqctl wait
# will not be able to make sense of it anyway
;;
- *) mkdir -p $(dirname ${RABBITMQ_PID_FILE});
- echo $$ > ${RABBITMQ_PID_FILE}
- ;;
+ *) # When -detached is passed, we don't write the pid, since it'd be the
+ # wrong one
+ detached=""
+ for opt in "$@"; do
+ if [ "$opt" = "-detached" ]; then
+ detached="true"
+ fi
+ done
+ if [ ! $detached ]; then
+ mkdir -p $(dirname ${RABBITMQ_PID_FILE});
+ echo $$ > ${RABBITMQ_PID_FILE}
+ fi
esac
RABBITMQ_EBIN_ROOT="${RABBITMQ_HOME}/ebin"