Skip to content

Commit bebb2b0

Browse files
authored
Merge pull request #271 from muesli/daemon-helpers
daemon: add convenience constants for SdNotify
2 parents 1ae4dd7 + 39ad653 commit bebb2b0

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

daemon/sdnotify.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ import (
2626
"os"
2727
)
2828

29+
const (
30+
// SdNotifyReady tells the service manager that service startup is finished
31+
// or the service finished loading its configuration.
32+
SdNotifyReady = "READY=1"
33+
34+
// SdNotifyStopping tells the service manager that the service is beginning
35+
// its shutdown.
36+
SdNotifyStopping = "STOPPING=1"
37+
38+
// SdNotifyReloading tells the service manager that this service is
39+
// reloading its configuration. Note that you must call SdNotifyReady when
40+
// it completed reloading.
41+
SdNotifyReloading = "RELOADING=1"
42+
43+
// SdNotifyWatchdog tells the service manager to update the watchdog
44+
// timestamp for the service.
45+
SdNotifyWatchdog = "WATCHDOG=1"
46+
)
47+
2948
// SdNotify sends a message to the init daemon. It is common to ignore the error.
3049
// If `unsetEnvironment` is true, the environment variable `NOTIFY_SOCKET`
3150
// will be unconditionally unset.

daemon/watchdog.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ import (
2121
"time"
2222
)
2323

24-
// SdWatchdogEnabled return watchdog information for a service.
25-
// Process should send daemon.SdNotify("WATCHDOG=1") every time / 2.
26-
// If `unsetEnvironment` is true, the environment variables `WATCHDOG_USEC`
27-
// and `WATCHDOG_PID` will be unconditionally unset.
24+
// SdWatchdogEnabled returns watchdog information for a service.
25+
// Processes should call daemon.SdNotify(false, daemon.SdNotifyWatchdog) every
26+
// time / 2.
27+
// If `unsetEnvironment` is true, the environment variables `WATCHDOG_USEC` and
28+
// `WATCHDOG_PID` will be unconditionally unset.
2829
//
2930
// It returns one of the following:
3031
// (0, nil) - watchdog isn't enabled or we aren't the watched PID.

0 commit comments

Comments
 (0)