blob: 46f9e8ef7cf41051cb4a66247537a17ca7628157 (
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
|
module Propellor.Property.Service where
import Propellor.Base
type ServiceName = String
-- | Ensures that a service is running. Does not ensure that
-- any package providing that service is installed. See
-- Apt.serviceInstalledRunning
--
-- Note that due to the general poor state of init scripts, the best
-- we can do is try to start the service, and if it fails, assume
-- this means it's already running.
running :: ServiceName -> Property DebianLike
running = signaled "start" "running"
restarted :: ServiceName -> Property DebianLike
restarted = signaled "restart" "restarted"
reloaded :: ServiceName -> Property DebianLike
reloaded = signaled "reload" "reloaded"
signaled :: String -> Desc -> ServiceName -> Property DebianLike
signaled cmd desc svc = tightenTargets $ p `describe` (desc ++ " " ++ svc)
where
p = scriptProperty ["service " ++ shellEscape svc ++ " " ++ cmd ++ " >/dev/null 2>&1 || true"]
`assume` NoChange
|