Defined Type: supervisor::app

Defined in:
manifests/app.pp

Overview

Parameters:

  • app_name (Any) (defaults to: $title)
  • command (Any)
  • directory (Any)
  • user (Any) (defaults to: 'root')
  • startsecs (Any) (defaults to: undef)
  • stopwaitsecs (Any) (defaults to: undef)
  • priority (Any) (defaults to: undef)
  • environment (Any) (defaults to: undef)
  • stopsignal (Any) (defaults to: undef)


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
# File 'manifests/app.pp', line 1

define supervisor::app (
  $app_name = $title,
  $command,
  $directory,
  $user = 'root',
  $startsecs = undef,
  $stopwaitsecs = undef,
  $priority = undef,
  $environment = undef,
  $stopsignal = undef,
) {

  $conf_file = "supervisor_${app_name}"
  $service_name = $conf_file

  file { $conf_file:
    path    => "/etc/supervisor/conf.d/${app_name}.conf",
    ensure  => present,
    content => template('supervisor/supervisor.conf.erb'),
    require => Pip::Install['supervisor'],
    notify  => Service['supervisord'],
  }

  service { $service_name:
    ensure     => running,
    path       =>  ['/usr/bin'],
    start      => "supervisorctl start $app_name",
    restart    => "supervisorctl restart $app_name",
    stop       => "supervisorctl stop $app_name",
    status     => "supervisorctl status | awk '/^${name}[: ]/{print \$2}' | grep '^RUNNING$'",
    subscribe  => File[$conf_file], 
    hasrestart => false, 
    hasstatus  => false,
    provider   => base
  }
}