aboutsummaryrefslogtreecommitdiff
path: root/manifests/app.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/app.pp')
-rw-r--r--manifests/app.pp33
1 files changed, 33 insertions, 0 deletions
diff --git a/manifests/app.pp b/manifests/app.pp
new file mode 100644
index 0000000..aef36d2
--- /dev/null
+++ b/manifests/app.pp
@@ -0,0 +1,33 @@
+define supervisor::app (
+ $command,
+ $directory,
+ $appname = $name,
+ $ensure = running,
+ $user = 'www-data',
+) {
+
+ $conf_title = "supervisor-${appname}"
+ $service_title = $conf_title
+
+ file { $conf_title:
+ path => "/etc/supervisor/conf.d/${appname}.conf",
+ ensure => present,
+ content => template('supervisor/app.erb'),
+ require => Package['supervisor'],
+ notify => Service['supervisor'],
+ }
+
+ service { $service_title:
+ ensure => $ensure,
+ path => ['/usr/bin'],
+ start => "supervisorctl start $appname",
+ restart => "supervisorctl restart $appname",
+ stop => "supervisorctl stop $appname",
+ status => "supervisorctl status | awk '/^${appname}[: ]/{print \$2}' | grep '^RUNNING$'",
+ subscribe => File[$conf_title],
+ hasrestart => false,
+ hasstatus => false,
+ provider => base
+ }
+
+}