Ensure that exit code 0 is used for "stop" command #1381
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #693 and #151098578 in tracker.
These changes are already in the
stablebranch as they were not reverted there: https://github.com/rabbitmq/rabbitmq-server/blob/stable/src/rabbit_cli.erl#L117-L146I found issue #693 and it turns out that, yes,
systemddoes look at the exit status of theExecStopcommand to determine if therabbitmq-server.serviceunit should be put into a failed state. Here is the problematic sequence of events as provided by @dumbbell in #693:rabbitmqctl stopwhich causes RabbitMQ server to eventually exit with status0systemdnotices that the server process exited, and runs theExecStopcommand -rabbitmqctl stoprabbitmqctl stopreturns anything other than0,systemdputs the unit into a failed stateThe other reason
rabbitmqctl stopcould (or should) exit with0is due to the change introduced in rabbitmq/rabbitmq-server-release#49. With the change toRestart=on-failure, the above sequence of events would causesystemdto restart RabbitMQ ifrabbitmqctl stopreturns69during theExecStopphase.Other Options
Introduce a
safe_stopcommand forrabbitmqctlthat will always return0. This command could also check to see if theRABBITMQ_PID_FILEenvironment variable is set and use it to synchronously wait for the server to exit, which would remove the need for this code. The code to wait for RabbitMQ to exit is already available.Use the
systemdSuccessExitStatus=69setting. I have tested it andsystemddoes consider the code to be OK from theExecStopcommand: