blob: d750914ceb87e1983254640e2899726a6619a7bc (
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
|
define runit::service::enabled( $ensure = present ) {
# enabling the service by creating a symlink in /etc/service
file { "/etc/service/${name}":
target => "/etc/sv/${name}",
ensure => $ensure ? {
present => link,
default => absent,
},
}
if $ensure == present {
# subscribe to any run file changes
File["/etc/sv/${name}/run"] ~> Runit::Service::Enabled[$name]
# we also require notification from all environment variables
Runit::Service::Env <| service == $name |> {
notify +> Runit::Service::Enabled[$name]
}
exec { "sv restart ${name}":
subscribe => File["/etc/service/${name}"],
# we wait a few seconds just in case this is the firstmost service activation
# then the supervise directory need to be created (automically) by runit
command => "/bin/sleep 3; /usr/bin/sv -w 60 restart /etc/sv/${name}",
refreshonly => true,
}
}
}
|