Skip to content

Commit de8df83

Browse files
author
Loïc Hoguin
committed
make: Easy code reloading for run-broker/start-cluster
This enables code reloading for single nodes and for clusters. For single nodes using `make run-broker` at least two terminals must be used: the one with the broker, and the one doing the reloading. When only using a single node (`make run-broker`), the `RELOAD=1` variable can be passed to Make when recompiling. This will lead to code reloading at the end of compilation. make RELOAD=1 Alternatively the "reload-broker" target can be used: make all reload-broker Special care must be given when the -j flag is used. In that case it may be needed to separate compilation and reloading in two separate calls: make && make reload-broker The same considerations apply to clusters, only there isn't a shorthand variable for them. Instead, the "reload-cluster" target must be used: make all reload-cluster Or: make && make reload-cluster Either of these will compile and reload the modules on all nodes of the cluster. It is also possible to reload modules only on some nodes, using `make reload-broker` with the variable "RABBITMQ_NODENAME" set to the node you want to trigger a reload on. This could be used to test scenarios where the code differs between the nodes in the cluster.
1 parent 769f19b commit de8df83

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

deps/rabbit_common/mk/rabbitmq-run.mk

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,42 @@ stop-brokers stop-cluster:
416416
done; \
417417
wait
418418

419+
# --------------------------------------------------------------------
420+
# Code reloading.
421+
#
422+
# For `make run-broker` either do:
423+
# * make RELOAD=1
424+
# * make all reload-broker (can't do this alongside -j flag)
425+
# * make && make reload-broker (fine with -j flag)
426+
#
427+
# Or if recompiling a specific application:
428+
# * make -C deps/rabbit RELOAD=1
429+
#
430+
# For `make start-cluster` use the `reload-cluster` target.
431+
# Same constraints apply as with `reload-broker`:
432+
# * make all reload-cluster
433+
# * make && make reload-cluster
434+
# --------------------------------------------------------------------
435+
436+
reload-broker:
437+
$(exec_verbose) ERL_LIBS="$(DIST_ERL_LIBS)" \
438+
$(RABBITMQCTL) -n $(RABBITMQ_NODENAME) \
439+
eval "io:format(\"~p~n\", [c:lm()])."
440+
441+
ifeq ($(MAKELEVEL),0)
442+
ifdef RELOAD
443+
all:: reload-broker
444+
endif
445+
endif
446+
447+
reload-cluster:
448+
@for n in $$(seq $(NODES) -1 1); do \
449+
nodename="rabbit-$$n@$(HOSTNAME)"; \
450+
$(MAKE) reload-broker \
451+
RABBITMQ_NODENAME="$$nodename" & \
452+
done; \
453+
wait
454+
419455
# --------------------------------------------------------------------
420456
# Used by testsuites.
421457
# --------------------------------------------------------------------

0 commit comments

Comments
 (0)