]> git.openstreetmap.org Git - chef.git/commitdiff
Convert tile replication to a native systemd service
authorTom Hughes <tom@compton.nu>
Mon, 12 Sep 2016 21:31:01 +0000 (22:31 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 12 Sep 2016 21:34:25 +0000 (22:34 +0100)
cookbooks/tile/recipes/default.rb
cookbooks/tile/templates/default/replicate.init.erb [deleted file]

index f8a808d737873e27be7b8c8a09b7ea20af836929..c17800156a2b91e5d57525127a4639df036bf38b 100644 (file)
@@ -457,18 +457,23 @@ template "/usr/local/bin/replicate" do
   mode 0o755
 end
 
   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]
 end
 
 service "replicate" do
   action [:enable, :start]
-  supports :restart => true
   subscribes :restart, "template[/usr/local/bin/replicate]"
   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
 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 (file)
index b7c6220..0000000
+++ /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