-
-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathsystemd.go
More file actions
28 lines (24 loc) · 595 Bytes
/
systemd.go
File metadata and controls
28 lines (24 loc) · 595 Bytes
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
//go:build !darwin && !windows
package main
import (
"github.com/coreos/go-systemd/v22/daemon"
"github.com/creativeprojects/clog"
)
func notifyStart() {
ok, err := daemon.SdNotify(false, daemon.SdNotifyReady)
if err != nil {
clog.Errorf("cannot notify systemd: %w", err)
}
if ok {
clog.Debug("running as a systemd unit: sending 'ready' status")
}
}
func notifyStop() {
ok, err := daemon.SdNotify(false, daemon.SdNotifyStopping)
if err != nil {
clog.Errorf("cannot notify systemd: %w", err)
}
if ok {
clog.Debug("running as a systemd unit: sending 'stopping' status")
}
}