Skip to content

Commit c5f0c35

Browse files
lukebakkenmergify[bot]
authored andcommitted
Restore -detached argument detection in rabbitmq-server
Commit 68c3055 removed the code that detected the `-detached` command-line argument and set the `detached` variable. However, the conditional check for `$detached` remained, along with a comment referencing "the code above" that no longer exists. This left orphaned code that could never execute its intended branch. This change restores the argument detection loop that sets `detached` to `"true"` when `-detached` is found in the command-line arguments. The loop uses POSIX-compliant syntax to iterate through all positional parameters and check for the `-detached` flag. Additionally, this change replaces the deprecated `-o` operator with `||` in the conditional test, following POSIX best practices for boolean OR operations in shell scripts. (cherry picked from commit a48ea81) (cherry picked from commit 6218d57)
1 parent 138a30d commit c5f0c35

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

deps/rabbit/scripts/rabbitmq-server

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ SCRIPTS_DIR=$(dirname "$0")
1616

1717
[ "$NOTIFY_SOCKET" ] && RUNNING_UNDER_SYSTEMD=true
1818

19+
for opt in "$@"; do
20+
if [ "$opt" = "-detached" ]; then
21+
detached="true"
22+
fi
23+
done
24+
1925
RABBITMQ_DEFAULT_ALLOC_ARGS="+MBas ageffcbf +MHas ageffcbf +MBlmbcs 512 +MHlmbcs 512 +MMmcs 30"
2026

2127
check_start_params() {
@@ -94,13 +100,12 @@ stop_rabbitmq_server() {
94100
fi
95101
}
96102

97-
if [ "$RABBITMQ_ALLOW_INPUT" -o "$RUNNING_UNDER_SYSTEMD" -o "$detached" ]; then
98-
# Run erlang VM directly, completely replacing current shell
99-
# process - so the pid file written in the code above will be
100-
# valid (unless detached, which is also handled in the code
101-
# above).
103+
# Note: the docker-library/rabbitmq#778 change exports "RUNNING_UNDER_SYSTEMD=true" to start
104+
# the erl process using exec via the start_rabbitmq_server.
105+
if [ "$RABBITMQ_ALLOW_INPUT" ] || [ "$RUNNING_UNDER_SYSTEMD" ] || [ "$detached" ]; then
106+
# Run erlang VM directly, completely replacing current shell process
102107
#
103-
# And also this is the correct mode to run the broker under
108+
# This is also the correct mode to run the broker under
104109
# systemd - there is no need in a proxy process that converts
105110
# signals to graceful shutdown command, the unit file should already
106111
# contain instructions for graceful shutdown. Also by removing

0 commit comments

Comments
 (0)