Add optional Restart and RestartSec configuration

See rabbitmq/rabbitmq-server#1359

This gives guidances for those users who wish to automatically restart RabbitMQ in the event of a failure. Tested by using the `Restart=on-failure` setting, then running `rabbitmqctl eval "erlang:halt(abort)."`
This commit is contained in:
Luke Bakken 2017-09-19 15:54:57 -07:00
parent 1932662f98
commit 07ad84c66a
No known key found for this signature in database
GPG Key ID: B707DD932540186E
2 changed files with 18 additions and 2 deletions

View File

@ -6,12 +6,20 @@ After=syslog.target network.target
Type=notify
User=rabbitmq
Group=rabbitmq
NotifyAccess=all
TimeoutStartSec=3600
# Note:
# You *may* wish to add the following to automatically restart RabbitMQ
# in the event of a failure. systemd service restarts are not a
# replacement for service monitoring. Please see
# http://www.rabbitmq.com/monitoring.html
#
# Restart=on-failure # https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=
# RestartSec=10 # https://www.freedesktop.org/software/systemd/man/systemd.service.html#RestartSec=
WorkingDirectory=/var/lib/rabbitmq
ExecStart=/usr/sbin/rabbitmq-server
ExecStop=/usr/sbin/rabbitmqctl stop
ExecStop=/bin/sh -c "while ps -p $MAINPID >/dev/null 2>&1; do sleep 1; done"
NotifyAccess=all
TimeoutStartSec=3600
[Install]
WantedBy=multi-user.target

View File

@ -10,6 +10,14 @@ User=rabbitmq
Group=rabbitmq
NotifyAccess=all
TimeoutStartSec=3600
# Note:
# You *may* wish to add the following to automatically restart RabbitMQ
# in the event of a failure. systemd service restarts are not a
# replacement for service monitoring. Please see
# http://www.rabbitmq.com/monitoring.html
#
# Restart=on-failure # https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=
# RestartSec=10 # https://www.freedesktop.org/software/systemd/man/systemd.service.html#RestartSec=
WorkingDirectory=/var/lib/rabbitmq
ExecStart=/usr/lib/rabbitmq/bin/rabbitmq-server
ExecStop=/usr/lib/rabbitmq/bin/rabbitmqctl stop