diff options
| -rw-r--r-- | CHANGELOG.adoc | 4 | ||||
| -rw-r--r-- | cmd/httpdfs/main.go | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a0f4c5cd..33346064 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -38,6 +38,10 @@ Legend, [#v0_61_0] == pakakeh.go v0.61.0 (2026-xx-xx) +**🌼 cmd/httpdfs: implement systemd socket activation** + +The httpdfs program now can be activated using systemd.socket(5). + **🌼 lib/http: add field Listener to ServerOptions** The field Listener allow user to pass [net.Listener] for accepting new diff --git a/cmd/httpdfs/main.go b/cmd/httpdfs/main.go index c2f377ac..88573ded 100644 --- a/cmd/httpdfs/main.go +++ b/cmd/httpdfs/main.go @@ -16,6 +16,7 @@ import ( pakakeh "git.sr.ht/~shulhan/pakakeh.go" libhttp "git.sr.ht/~shulhan/pakakeh.go/lib/http" "git.sr.ht/~shulhan/pakakeh.go/lib/memfs" + "git.sr.ht/~shulhan/pakakeh.go/lib/systemd" ) const ( @@ -91,6 +92,22 @@ func main() { httpd *libhttp.Server ) + listeners, err := systemd.Listeners(true) + if err != nil { + log.Fatal(err) + } + if len(listeners) > 1 { + log.Fatal(`too many listeners received for activation`) + } + if len(listeners) == 1 { + serverOpts.Listener = listeners[0] + gotAddr := serverOpts.Listener.Addr().String() + if gotAddr != serverOpts.Address { + log.Fatal(`invalid Listener address, got %s, want %s`, + gotAddr, serverOpts.Address) + } + } + httpd, err = libhttp.NewServer(serverOpts) if err != nil { log.Fatalf(`%s: %s`, cmdName, err) |
