aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-02-02 21:05:15 +0700
committerShulhan <ms@kilabit.info>2026-02-02 21:05:15 +0700
commitca3002fb7041a863600042f013e12faf73caf227 (patch)
tree144a891b064d7cd43f9f3abf07e3ff7e13445de1
parent1e3bb9be8444082dc1ada7f76a727b9a9f764d47 (diff)
downloadpakakeh.go-ca3002fb7041a863600042f013e12faf73caf227.tar.xz
cmd/httpdfs: implement systemd socket activation
The httpdfs program now can be activated using systemd.socket(5).
-rw-r--r--CHANGELOG.adoc4
-rw-r--r--cmd/httpdfs/main.go17
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)