diff options
Diffstat (limited to 'internal/supervisor/systemd.go')
| -rw-r--r-- | internal/supervisor/systemd.go | 22 | +18 −4 |
1 files changed, 18 insertions, 4 deletions
diff --git a/internal/supervisor/systemd.go b/internal/supervisor/systemd.go index 63c1c0d..ac57659 100644 --- a/internal/supervisor/systemd.go +++ b/internal/supervisor/systemd.go @@ -1,6 +1,8 @@ // Copyright (c) 2026 Nikolay Govorov // SPDX-License-Identifier: AGPL-3.0-or-later +//go:build linux + package supervisor import ( @@ -12,15 +14,23 @@ import ( "syscall" "time" + "net" + + "github.com/coreos/go-systemd/v22/activation" "github.com/coreos/go-systemd/v22/daemon" ) -type systemd struct{} - -func detectSystemd() bool { - return os.Getenv("NOTIFY_SOCKET") != "" +func init() { + register(func() Supervisor { + if os.Getenv("NOTIFY_SOCKET") != "" { + return &systemd{} + } + return nil + }) } +type systemd struct{} + func (*systemd) WaitForStop(ctx context.Context) context.Context { ctx, stop := signal.NotifyContext(ctx, syscall.SIGTERM, syscall.SIGINT) _ = stop // stop allows you to cancel the observer, but it's not particularly useful @@ -67,3 +77,7 @@ func (*systemd) StartWatchdog(ctx context.Context) { } } } + +func (*systemd) ActivationListeners() (map[string][]net.Listener, error) { + return activation.ListenersWithNames() +} |
