From 4ec27e687422ba3e9840b998987c73e1758fc1d3 Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Thu, 17 Aug 2017 11:42:31 -0500 Subject: [PATCH] Add automatic restart for memcached This patch ensures that systemd will restart memcached in case of failure or if the process is manually killed. Closes-Bug: 1659954 Change-Id: I6782320bf429cde17dff00401e7f136cfc979cee --- tasks/memcached_config.yml | 8 ++++++++ templates/systemd-restart-on-failure.conf.j2 | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 templates/systemd-restart-on-failure.conf.j2 diff --git a/tasks/memcached_config.yml b/tasks/memcached_config.yml index 7f7e71e..fab9e11 100644 --- a/tasks/memcached_config.yml +++ b/tasks/memcached_config.yml @@ -71,6 +71,14 @@ - ansible_service_mgr == 'systemd' notify: Restart memcached +- name: Add automatic restart on failure + template: + src: systemd-restart-on-failure.conf.j2 + dest: "/etc/systemd/system/memcached.service.d/systemd-restart-on-failure.conf" + when: + - ansible_service_mgr == 'systemd' + notify: Restart memcached + - name: Apply resource limits (systemd) template: src: "limits.conf.j2" diff --git a/templates/systemd-restart-on-failure.conf.j2 b/templates/systemd-restart-on-failure.conf.j2 new file mode 100644 index 0000000..8acdc0f --- /dev/null +++ b/templates/systemd-restart-on-failure.conf.j2 @@ -0,0 +1,4 @@ +# {{ ansible_managed }} +[Service] +Restart=on-failure +RestartSec=2