MCPcopy Create free account
hub / github.com/PostHog/duckgres / sdNotify

Function sdNotify

controlplane/sdnotify.go:11–27  ·  view source on GitHub ↗

sdNotify sends a notification to systemd via the NOTIFY_SOCKET. If NOTIFY_SOCKET is not set (i.e. not running under systemd), this is a no-op.

(state string)

Source from the content-addressed store, hash-verified

9// sdNotify sends a notification to systemd via the NOTIFY_SOCKET.
10// If NOTIFY_SOCKET is not set (i.e. not running under systemd), this is a no-op.
11func sdNotify(state string) error {
12 socketPath := os.Getenv("NOTIFY_SOCKET")
13 if socketPath == "" {
14 return nil
15 }
16
17 conn, err := net.Dial("unixgram", socketPath)
18 if err != nil {
19 return fmt.Errorf("dial NOTIFY_SOCKET: %w", err)
20 }
21 defer func() { _ = conn.Close() }()
22
23 if _, err := conn.Write([]byte(state)); err != nil {
24 return fmt.Errorf("write to NOTIFY_SOCKET: %w", err)
25 }
26 return nil
27}

Callers 2

RunControlPlaneFunction · 0.85
handleUpgradeMethod · 0.85

Calls 2

CloseMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected