aboutsummaryrefslogtreecommitdiff
path: root/manifests/app.pp
blob: 9ea90f1132d8ba47ffc1e7feb7eea997527b1b95 (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
34
35
36
37
38
39
40
41
42
43
44
define supervisor::app (
  $command = false,
  $directory = false,
  $appname = $name,
  $ensure = running,
  $user = 'www-data',
  $source = ''
) {
  
  $conf_title    = "supervisor-${appname}"
  $service_title = $conf_title

  file { $conf_title:
    path    => "/etc/supervisor/conf.d/${appname}.conf",
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => '0644',
    content => $source ? {
        ''      => template('supervisor/app.erb'),
        default => undef,
    },
    source  => $source ? {
        ''      => undef,
        default => $source,
    },
    require => File['/etc/supervisor/conf.d'],
    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  
  }

}