aboutsummaryrefslogtreecommitdiff
path: root/manifests/app.pp
blob: aef36d2fd8f903b97391c37a898c73acbcd1fe3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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  
  }

}