[Queens-only] Ensure epmd is spawned by systemd before redeploy
On (re)deploy, we forcibly restart epmd and rabbit to ensure any upgrade of erlang or rabbitmq can be taken into account before puppet runs. But there is currently no guarantee as to which one of systemd or rabbitmq will restart epmd. This is an improvement over I6f486b0b70f19d8b4916ef500675c0739939e060, to selectively kill epmd and ensure the systemd service will always restart it, like it is supposed to. Change-Id: I82b419cfe4585a3f185687b8cc0a19bb534f7536 Closes-Bug: #1823003
This commit is contained in:
@@ -6,14 +6,30 @@ set -eux
|
||||
#
|
||||
# To start undercloud deployment from a known state, restart any
|
||||
# running epmd/rabbitmq processes here. epmd can be started by either
|
||||
# systemd or rabbitmq, so try not to special-case it and kill the
|
||||
# processes we find. Restarting rabbitmq will restart epmd
|
||||
# automatically.
|
||||
# systemd or rabbitmq, so try to kill all the relevant processes.
|
||||
# Restarting rabbitmq will restart epmd automatically.
|
||||
#
|
||||
# Note: this has to run before 50-puppet-stack-config, i.e. before
|
||||
# any puppet/facter call to rabbitmq.
|
||||
|
||||
for pid in $(pgrep epmd); do kill $pid; done
|
||||
RESTART_RABBITMQ=
|
||||
|
||||
# If RabbitMQ is running, stop it and try to stop the epmd process
|
||||
# it may have spawned
|
||||
if systemctl is-active rabbitmq-server; then
|
||||
systemctl restart rabbitmq-server
|
||||
RESTART_RABBITMQ=yes
|
||||
systemctl stop rabbitmq-server
|
||||
pgrep -u rabbitmq -f 'epmd.*-daemon' | xargs -r kill
|
||||
fi
|
||||
|
||||
# If epmd was started by systemd, restart it now to give it a
|
||||
# chance to use the up-to-date Erlang runtime on the system.
|
||||
# Since no epmd from RabbitMQ is running at this point, the
|
||||
# epmd start by systemd should succeed in binding to the
|
||||
# listen address and service should always start
|
||||
systemctl try-restart epmd@*
|
||||
|
||||
# If we stopped RabbitMQ earlier, restart it now
|
||||
if [ -n "$RESTART_RABBITMQ" ]; then
|
||||
systemctl start rabbitmq-server
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user