From 915f41919a3eadbd602fc0b9c0cf01f3523cbe78 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 20 Oct 2016 11:29:40 +0100 Subject: [PATCH] Convert api-statistics to a systemd service --- cookbooks/web/recipes/rails.rb | 18 +++++++++----- .../templates/default/api-statistics.init.erb | 24 ------------------- 2 files changed, 12 insertions(+), 30 deletions(-) delete mode 100644 cookbooks/web/templates/default/api-statistics.init.erb diff --git a/cookbooks/web/recipes/rails.rb b/cookbooks/web/recipes/rails.rb index 52aa09625..02c094359 100644 --- a/cookbooks/web/recipes/rails.rb +++ b/cookbooks/web/recipes/rails.rb @@ -101,18 +101,24 @@ template "/usr/local/bin/api-statistics" do 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]" - subscribes :restart, "template[/etc/init.d/api-statistics]" + subscribes :restart, "systemd_service[api-statistics]" 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 index 880f1dad9..000000000 --- a/cookbooks/web/templates/default/api-statistics.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 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 -- 2.43.2