From 77b589abca2c670e5314a318b2b52aa0668a0dc3 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 12 Sep 2016 22:31:01 +0100 Subject: [PATCH] Convert tile replication to a native systemd service --- cookbooks/tile/recipes/default.rb | 19 +++++++++------ .../tile/templates/default/replicate.init.erb | 24 ------------------- 2 files changed, 12 insertions(+), 31 deletions(-) delete mode 100644 cookbooks/tile/templates/default/replicate.init.erb diff --git a/cookbooks/tile/recipes/default.rb b/cookbooks/tile/recipes/default.rb index f8a808d73..c17800156 100644 --- a/cookbooks/tile/recipes/default.rb +++ b/cookbooks/tile/recipes/default.rb @@ -457,18 +457,23 @@ template "/usr/local/bin/replicate" do mode 0o755 end -template "/etc/init.d/replicate" do - source "replicate.init.erb" - owner "root" - group "root" - mode 0o755 +systemd_service "replicate" do + description "Rendering database replication service" + after "postgresql.service" + wants "postgresql.service" + user "tile" + exec_start "/usr/local/bin/replicate" + private_tmp true + private_devices true + protect_system "full" + protect_home true + restart "on-failure" end service "replicate" do action [:enable, :start] - supports :restart => true subscribes :restart, "template[/usr/local/bin/replicate]" - subscribes :restart, "template[/etc/init.d/replicate]" + subscribes :restart, "systemd_service[replicate]" end template "/etc/logrotate.d/replicate" do diff --git a/cookbooks/tile/templates/default/replicate.init.erb b/cookbooks/tile/templates/default/replicate.init.erb deleted file mode 100644 index b7c6220fb..000000000 --- a/cookbooks/tile/templates/default/replicate.init.erb +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# DO NOT EDIT - This file is being maintained by Chef - -start() { - start-stop-daemon --start --chuid tile --background --make-pidfile --pidfile /var/run/replicate.pid --exec /usr/local/bin/replicate -} - -stop() { - start-stop-daemon --stop --retry 300 --pidfile /var/run/replicate.pid -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop || exit $? - start - ;; -esac -- 2.39.5