]> git.openstreetmap.org Git - chef.git/commitdiff
Convert api-statistics to a systemd service
authorTom Hughes <tom@compton.nu>
Thu, 20 Oct 2016 10:29:40 +0000 (11:29 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 20 Oct 2016 10:29:40 +0000 (11:29 +0100)
cookbooks/web/recipes/rails.rb
cookbooks/web/templates/default/api-statistics.init.erb [deleted file]

index 52aa09625c447bcd3377025ea4f3e742d84f3e2b..02c0943591cce1091547d6578b8e5963355475c6 100644 (file)
@@ -101,18 +101,24 @@ template "/usr/local/bin/api-statistics" do
   mode 0o755
 end
 
   mode 0o755
 end
 
-template "/etc/init.d/api-statistics" do
-  source "api-statistics.init.erb"
-  owner "root"
-  group "root"
-  mode 0o755
+systemd_service "api-statistics" do
+  description "OpenStreetMap API Statistics Daemon"
+  user "rails"
+  group "adm"
+  exec_start "/usr/local/bin/api-statistics"
+  private_tmp true
+  private_devices true
+  private_network true
+  protect_system "full"
+  protect_home true
+  restart "on-failure"
 end
 
 service "api-statistics" do
   action [:enable, :start]
   supports :restart => true
   subscribes :restart, "template[/usr/local/bin/api-statistics]"
 end
 
 service "api-statistics" do
   action [:enable, :start]
   supports :restart => true
   subscribes :restart, "template[/usr/local/bin/api-statistics]"
-  subscribes :restart, "template[/etc/init.d/api-statistics]"
+  subscribes :restart, "systemd_service[api-statistics]"
 end
 
 gem_package "hpricot"
 end
 
 gem_package "hpricot"
diff --git a/cookbooks/web/templates/default/api-statistics.init.erb b/cookbooks/web/templates/default/api-statistics.init.erb
deleted file mode 100644 (file)
index 880f1da..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 rails:adm --background --make-pidfile --pidfile /var/run/api-statistics.pid --exec /usr/local/bin/api-statistics
-}
-
-stop() {
-  start-stop-daemon --stop --retry 300 --pidfile /var/run/api-statistics.pid
-}
-
-case "$1" in
-  start)
-    start
-    ;;
-  stop)
-    stop
-    ;;
-  restart)
-    stop || exit $?
-    start
-    ;;
-esac