]> git.openstreetmap.org Git - chef.git/commitdiff
Convert gps-update service to a systemd unit
authorTom Hughes <tom@compton.nu>
Sun, 26 Feb 2017 10:40:04 +0000 (10:40 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 26 Feb 2017 10:54:55 +0000 (10:54 +0000)
cookbooks/gps-tile/metadata.rb
cookbooks/gps-tile/recipes/default.rb
cookbooks/gps-tile/templates/default/update.init.erb [deleted file]
cookbooks/systemd/resources/service.rb
cookbooks/systemd/templates/default/service.erb

index 4ce457d420262f4a0bd0665d14a8f5129acfbe44..53a5fb75f5ee7ccd7c57f8c49d0eccdccbde6d82 100644 (file)
@@ -6,3 +6,4 @@ description       "Configures a GPS tile server"
 long_description  IO.read(File.join(File.dirname(__FILE__), "README.md"))
 version           "1.0.0"
 depends           "apache"
 long_description  IO.read(File.join(File.dirname(__FILE__), "README.md"))
 version           "1.0.0"
 depends           "apache"
+depends           "systemd"
index ed60f1fd7619fedd456157caad50a2a9acd2f2ed..f2104bc46136775c00926873c0a3113560ec5fc0 100644 (file)
@@ -78,17 +78,25 @@ git "/srv/gps-tile.openstreetmap.org/updater" do
   group "gpstile"
 end
 
   group "gpstile"
 end
 
-template "/etc/init.d/gps-update" do
-  source "update.init.erb"
-  owner "root"
-  group "root"
-  mode 0o755
+systemd_service "gps-update" do
+  description "GPS tile update daemon"
+  after ["network.target", "memcached.service"]
+  wants ["memcached.service"]
+  user "gpstile"
+  working_directory "/srv/gps-tile.openstreetmap.org"
+  exec_start "/srv/gps-tile.openstreetmap.org/updater/update"
+  private_tmp true
+  private_devices true
+  protect_system "full"
+  protect_home true
+  no_new_privileges true
+  restart "on-failure"
 end
 
 service "gps-update" do
   action [:enable, :start]
 end
 
 service "gps-update" do
   action [:enable, :start]
-  supports :restart => true, :status => true
   subscribes :restart, "git[/srv/gps-tile.openstreetmap.org/updater]"
   subscribes :restart, "git[/srv/gps-tile.openstreetmap.org/updater]"
+  subscribes :restart, "systemd_service[gps-update]"
 end
 
 remote_directory "/srv/gps-tile.openstreetmap.org/html" do
 end
 
 remote_directory "/srv/gps-tile.openstreetmap.org/html" do
diff --git a/cookbooks/gps-tile/templates/default/update.init.erb b/cookbooks/gps-tile/templates/default/update.init.erb
deleted file mode 100644 (file)
index 1cf851d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-
-# DO NOT EDIT - This file is being maintained by Chef
-
-start() {
-  start-stop-daemon --start --chuid gpstile --chdir /srv/gps-tile.openstreetmap.org --background --make-pidfile --pidfile /var/run/gps-update.pid --exec /srv/gps-tile.openstreetmap.org/updater/update
-}
-
-stop() {
-  start-stop-daemon --stop --retry 300 --pidfile /var/run/gps-update.pid
-}
-
-status() {
-  start-stop-daemon --status --pidfile /var/run/gps-update.pid
-}
-
-case "$1" in
-  start)
-    start
-    ;;
-  stop)
-    stop
-    ;;
-  restart)
-    stop || exit $?
-    start
-    ;;
-  status)
-    status
-    exit $?
-    ;;
-esac
index 943ce031bbc8ae3f166770d2b499f5eb97d606c1..2a8f22b2b30547805e47869d2d558f418f58e1a3 100644 (file)
@@ -31,6 +31,7 @@ property :environment, Hash, :default => {}
 property :environment_file, [String, Hash]
 property :user, String
 property :group, String
 property :environment_file, [String, Hash]
 property :user, String
 property :group, String
+property :working_directory, String
 property :exec_start_pre, String
 property :exec_start, String, :required => true
 property :exec_start_post, String
 property :exec_start_pre, String
 property :exec_start, String, :required => true
 property :exec_start_post, String
@@ -51,6 +52,7 @@ property :private_devices, [TrueClass, FalseClass]
 property :private_network, [TrueClass, FalseClass]
 property :protect_system, [TrueClass, FalseClass, String]
 property :protect_home, [TrueClass, FalseClass, String]
 property :private_network, [TrueClass, FalseClass]
 property :protect_system, [TrueClass, FalseClass, String]
 property :protect_home, [TrueClass, FalseClass, String]
+property :no_new_privileges, [TrueClass, FalseClass]
 property :timeout_sec, Integer
 property :pid_file, String
 
 property :timeout_sec, Integer
 property :pid_file, String
 
index 703d6428144f21d77028cb1d247858bf3e23d5bb..ffc0efb7203e5da5696596f6109abba04c355e86 100644 (file)
@@ -26,6 +26,9 @@ User=<%= @user %>
 <% if @group -%>
 Group=<%= @group %>
 <% end -%>
 <% if @group -%>
 Group=<%= @group %>
 <% end -%>
+<% if @working_directory -%>
+WorkingDirectory=<%= @working_directory %>
+<% end -%>
 <% if @exec_start_pre -%>
 ExecStartPre=<%= @exec_start_pre %>
 <% end -%>
 <% if @exec_start_pre -%>
 ExecStartPre=<%= @exec_start_pre %>
 <% end -%>
@@ -69,6 +72,9 @@ ProtectSystem=<%= @protect_system %>
 <% if @protect_home -%>
 ProtectHome=<%= @protect_home %>
 <% end -%>
 <% if @protect_home -%>
 ProtectHome=<%= @protect_home %>
 <% end -%>
+<% if @no_new_privileges -%>
+NoNewPrivileges=<%= @no_new_privileges %>
+<% end -%>
 <% if @restart -%>
 Restart=<%= @restart %>
 <% end -%>
 <% if @restart -%>
 Restart=<%= @restart %>
 <% end -%>