Skip to content

Commit a1744a7

Browse files
dumbbellmergify[bot]
authored andcommitted
rabbitmq-run.mk: Stop node in start-background-broker in case of error
[Why] The CLI sometimes crashes early because it fails to configure the Erlang distribution. Because we use two CLI commands to watch the start of RabbitMQ, if one of them fails, the Make recipe will exit with an error, leaving the RabbitMQ node running. [How] We use a shell trap to stop the node if the shell is about to exit with an error. While here, we retry the `await_startup` CLI command several times because this is the one failing the most. This is until the crash is understood and a proper fix is committed. (cherry picked from commit 3a278e7) (cherry picked from commit 88958f3)
1 parent 3da9903 commit a1744a7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

deps/rabbit_common/mk/rabbitmq-run.mk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,13 @@ start-background-broker: node-tmpdir $(DIST_TARGET)
320320
$(BASIC_SCRIPT_ENV_SETTINGS) \
321321
$(RABBITMQ_SERVER) \
322322
$(REDIRECT_STDIO) &
323+
trap 'test "$$?" = 0 || $(MAKE) stop-node' EXIT && \
323324
ERL_LIBS="$(DIST_ERL_LIBS)" \
324325
$(RABBITMQCTL) -n $(RABBITMQ_NODENAME) wait --timeout $(RMQCTL_WAIT_TIMEOUT) $(RABBITMQ_PID_FILE) && \
325-
ERL_LIBS="$(DIST_ERL_LIBS)" \
326-
$(RABBITMQCTL) --node $(RABBITMQ_NODENAME) await_startup
326+
for i in $$(seq 1 10); do \
327+
ERL_LIBS="$(DIST_ERL_LIBS)" $(RABBITMQCTL) -n $(RABBITMQ_NODENAME) await_startup || sleep 1; \
328+
done && \
329+
ERL_LIBS="$(DIST_ERL_LIBS)" $(RABBITMQCTL) -n $(RABBITMQ_NODENAME) await_startup
327330

328331
start-rabbit-on-node:
329332
$(exec_verbose) ERL_LIBS="$(DIST_ERL_LIBS)" \

0 commit comments

Comments
 (0)