Merge pull request #17 from rabbitmq/improve-rabbitmq-healthcheck

Improve RabbitMQ HEALTHCHECK
This commit is contained in:
Tianon Gravi 2019-01-16 02:46:20 -08:00 committed by GitHub
commit 436d3437d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 7 deletions

View File

@ -1,11 +1,14 @@
#!/bin/bash
set -eo pipefail
host="$(hostname -s || echo 'localhost')"
export RABBITMQ_NODENAME="${RABBITMQ_NODENAME:-"rabbit@$host"}"
# A RabbitMQ node is considered healthy if all the below are true:
# * the rabbit app finished booting & it's running
# * there are no alarms
# * there is at least 1 active listener
if rabbitmqctl status; then
exit 0
fi
exit 1
rabbitmqctl eval '
{ true, rabbit_app_booted_and_running } = { rabbit:is_booted(node()), rabbit_app_booted_and_running },
{ [], no_alarms } = { rabbit:alarms(), no_alarms },
[] /= rabbit_networking:active_listeners(),
rabbitmq_node_is_healthy.
' || exit 1