Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/customservice/manifests/supervisor.pp

Issue 29329307: Issue 3211 - Integrate customservice::supervisor with notification daemon (Closed)
Patch Set: Issue 3211 - Address feedback from codereview Created Oct. 26, 2015, 12:14 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | modules/notificationserver/manifests/init.pp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/customservice/manifests/supervisor.pp
diff --git a/modules/customservice/manifests/supervisor.pp b/modules/customservice/manifests/supervisor.pp
new file mode 100644
index 0000000000000000000000000000000000000000..119fe0f425346fd9d2a316057e3c0e75d0fbabaa
--- /dev/null
+++ b/modules/customservice/manifests/supervisor.pp
@@ -0,0 +1,70 @@
+# == Type: customservice::supervisor
+#
+# Periodically check for and revive dead service processes.
+#
+# === Parameters:
+#
+# [*ensure*]
+# Whether to ensure the service record being 'present' or not within
+# the list of services recognized by the supervisor.
+#
+# [*name*]
+# The $name of the service, matching it's name in the init system, i.e.
+# the init-script's basename. Defaults to $title.
+#
+# [*pidfile*]
+# The path to the process ID file associated with the service, if present.
+#
+# === Examples:
+#
+# customservice::supervisor {'example':
+# name => 'sshd',
+# ensure => 'present',
+# }
+#
+# customservice::supervisor {'spawn-fcgi':
+# pidfile => '/var/run/500-example_spawn-fcgi.pid',
+# }
+#
+define customservice::supervisor (
+ $ensure = 'present',
+ $pidfile = "/var/run/$name.pid"
+) {
+
+ include sitescripts
+
+ $config = '/etc/customservice_supervisor.ini'
+ $module = 'sitescripts.management.bin.start_services'
+ $target = 'customservice::supervisor'
+
+ ensure_resource('concat', $target, {
+ path => $config,
+ })
+
+ ensure_resource('concat::fragment', $target, {
+ content => "[keep_alive_services]\n",
+ order => 0,
+ target => $target,
+ })
+
+ ensure_resource('cron', $target, {
+ command => "SITESCRIPTS_CONFIG=$config python -m $module",
+ environment => concat(hiera('cron::environment', []), [
+ 'PYTHONPATH=/opt/sitescripts',
+ ]),
+ require => [
+ Class['sitescripts'],
+ Concat::Fragment[$target],
+ ],
+ })
+
+ concat::fragment {"$target#$name":
+ content => "$name = $pidfile\n",
+ ensure => $ensure ? {
+ /^(absent|purged)$/ => 'absent',
+ default => 'present',
+ },
+ order => 1,
+ target => $target,
+ }
+}
« no previous file with comments | « no previous file | modules/notificationserver/manifests/init.pp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld