From be5daeba7ad6b9eb3a30a3fa84e58d3962322dbd Mon Sep 17 00:00:00 2001 From: state-plumber <273540141+state-plumber@users.noreply.github.com> Date: Sat, 11 Apr 2026 17:10:59 +0000 Subject: [PATCH] Add -notifyfd flag for s6-style readiness notification (#1337) Write a newline to the specified file-descriptor to signal that yggdrasil is fully initialised and ready. s6 service startup notifications are described [here](https://skarnet.org/software/s6/notifywhenup.html). Related: #1148 --- cmd/yggdrasil/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/yggdrasil/main.go b/cmd/yggdrasil/main.go index 0581e018..51893dad 100644 --- a/cmd/yggdrasil/main.go +++ b/cmd/yggdrasil/main.go @@ -55,6 +55,7 @@ func main() { getpkey := flag.Bool("publickey", false, "use in combination with either -useconf or -useconffile, outputs your public key") loglevel := flag.String("loglevel", "info", "loglevel to enable") chuserto := flag.String("user", "", "user (and, optionally, group) to set UID/GID to") + notifyFd := flag.Int("notifyfd", -1, "write a newline to this file-descriptor to indicate readiness to a service manager") flag.Parse() done := make(chan struct{}) @@ -313,6 +314,12 @@ func main() { panic(fmt.Sprintf("pledge: %v: %v", promises, err)) } + if notifyFd != nil && *notifyFd > 0 { + f := os.NewFile(uintptr(*notifyFd), "notifyfd") + _, _ = f.Write([]byte{0x0a}) + f.Close() + } + // Block until we are told to shut down. <-ctx.Done()