]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/web/recipes/gpx.rb
Update OTRS to 5.0.27
[chef.git] / cookbooks / web / recipes / gpx.rb
index 7806530d97f9c216ce2327e71593ce5c1195e2aa..4c1b87cb6a5a631782fc4b80354081c85c9da89b 100644 (file)
@@ -8,7 +8,7 @@
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
-#     http://www.apache.org/licenses/LICENSE-2.0
+#     https://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
@@ -21,16 +21,18 @@ include_recipe "web::base"
 
 db_passwords = data_bag_item("db", "passwords")
 
-package "gcc"
-package "make"
-package "pkg-config"
-package "libarchive-dev"
-package "libbz2-dev"
-package "libexpat1-dev"
-package "libgd2-noxpm-dev"
-package "libmemcached-dev"
-package "libpq-dev"
-package "zlib1g-dev"
+package %w[
+  gcc
+  make
+  pkg-config
+  libarchive-dev
+  libbz2-dev
+  libexpat1-dev
+  libgd2-noxpm-dev
+  libmemcached-dev
+  libpq-dev
+  zlib1g-dev
+]
 
 gpx_directory = "#{node[:web][:base_directory]}/gpx-import"
 pid_directory = node[:web][:pid_directory]
@@ -53,21 +55,33 @@ git gpx_directory do
   notifies :run, "execute[gpx-import-build]", :immediate
 end
 
-template "/etc/init.d/gpx-import" do
-  source "init.gpx.erb"
-  owner "root"
-  group "root"
-  mode 0o755
-  variables :gpx_directory => gpx_directory,
-            :pid_directory => pid_directory,
-            :log_directory => log_directory,
-            :database_host => node[:web][:database_host],
-            :database_name => "openstreetmap",
-            :database_username => "gpximport",
-            :database_password => db_passwords["gpximport"]
+systemd_service "gpx-import" do
+  description "GPX Import Daemon"
+  after "network.target"
+  type "forking"
+  environment_file "GPX_SLEEP_TIME" => "40",
+                   "GPX_PATH_TRACES" => "/store/rails/gpx/traces",
+                   "GPX_PATH_IMAGES" => "/store/rails/gpx/images",
+                   "GPX_PATH_TEMPLATES" => "#{gpx_directory}/templates/",
+                   "GPX_PGSQL_HOST" => node[:web][:database_host],
+                   "GPX_PGSQL_USER" => "gpximport",
+                   "GPX_PGSQL_PASS" => db_passwords["gpximport"],
+                   "GPX_PGSQL_DB" => "openstreetmap",
+                   "GPX_LOG_FILE" => "#{log_directory}/gpx-import.log",
+                   "GPX_PID_FILE" => "#{pid_directory}/gpx-import.pid",
+                   "GPX_MAIL_SENDER" => "bounces@openstreetmap.org"
+  user "rails"
+  exec_start "#{gpx_directory}/src/gpx-import"
+  exec_reload "/bin/kill -HUP $MAINPID"
+  private_tmp true
+  private_devices true
+  protect_system "full"
+  protect_home true
+  restart "on-failure"
+  pid_file "#{pid_directory}/gpx-import.pid"
 end
 
-if %w(database_offline database_readonly gpx_offline).include?(node[:web][:status])
+if %w[database_offline database_readonly gpx_offline].include?(node[:web][:status])
   service "gpx-import" do
     action :stop
   end
@@ -76,6 +90,6 @@ else
     action [:enable, :start]
     supports :restart => true, :reload => true
     subscribes :restart, "execute[gpx-import-build]"
-    subscribes :restart, "template[/etc/init.d/gpx-import]"
+    subscribes :restart, "systemd_service[gpx-import]"
   end
 end