Add automatic restart for RabbitMQ

This patch ensures that systemd will restart RabbitMQ in case of
failure or if the process is manually killed.

Closes-Bug: 1659954
Change-Id: Id8dbdccfe445f4a25902054eb6809d42a92d5f5d
This commit is contained in:
Major Hayden 2017-08-18 08:50:19 -05:00
parent 9f95b25476
commit e27a4b2851
No known key found for this signature in database
GPG Key ID: 737051E0C1011FB1
2 changed files with 17 additions and 2 deletions

View File

@ -60,10 +60,20 @@
- rabbitmq-config - rabbitmq-config
- name: Apply resource limits (systemd) - name: Apply resource limits (systemd)
register: rabbit_resource_limit_changed
template: template:
src: "limits.conf.j2" src: "limits.conf.j2"
dest: "/etc/systemd/system/rabbitmq-server.service.d/limits.conf" dest: "/etc/systemd/system/rabbitmq-server.service.d/limits.conf"
register: rabbit_resource_limit
when:
- ansible_service_mgr == 'systemd'
tags:
- rabbitmq-config
- name: Add automatic restart on failure
template:
src: systemd-restart-on-failure.conf.j2
dest: "/etc/systemd/system/rabbitmq-server.service.d/systemd-restart-on-failure.conf"
register: rabbit_restart_on_failure
when: when:
- ansible_service_mgr == 'systemd' - ansible_service_mgr == 'systemd'
tags: tags:
@ -73,7 +83,8 @@
command: "systemctl daemon-reload" command: "systemctl daemon-reload"
when: when:
- ansible_service_mgr == 'systemd' - ansible_service_mgr == 'systemd'
- rabbit_resource_limit_changed|changed - rabbit_resource_limit | changed
- rabbit_restart_on_failure | changed
tags: tags:
- rabbitmq-config - rabbitmq-config
# don't trigger ANSIBLE0016 # don't trigger ANSIBLE0016

View File

@ -0,0 +1,4 @@
# {{ ansible_managed }}
[Service]
Restart=on-failure
RestartSec=2