Skip to content

Commit 39ad653

Browse files
committed
daemon: Added notification consts for convenience
- SdNotifyReady to signal readiness - SdNotifyStopping to signal beginning of shutdown - SdNotifyReloading to signal configuration reloading - SdNotifyWatchdog to update the watchdog timestamp
1 parent d7b55e1 commit 39ad653

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
@@ -21,6 +21,25 @@ import (
2121
"os"
2222
)
2323

24+
const (
25+
// SdNotifyReady tells the service manager that service startup is finished
26+
// or the service finished loading its configuration.
27+
SdNotifyReady = "READY=1"
28+
29+
// SdNotifyStopping tells the service manager that the service is beginning
30+
// its shutdown.
31+
SdNotifyStopping = "STOPPING=1"
32+
33+
// SdNotifyReloading tells the service manager that this service is
34+
// reloading its configuration. Note that you must call SdNotifyReady when
35+
// it completed reloading.
36+
SdNotifyReloading = "RELOADING=1"
37+
38+
// SdNotifyWatchdog tells the service manager to update the watchdog
39+
// timestamp for the service.
40+
SdNotifyWatchdog = "WATCHDOG=1"
41+
)
42+
2443
// SdNotify sends a message to the init daemon. It is common to ignore the error.
2544
// If `unsetEnvironment` is true, the environment variable `NOTIFY_SOCKET`
2645
// 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)