feat: listen for SIGHUP if running in a terminal
4 files changed, 17 insertions(+), 5 deletions(-)
changed files
M cmd/searchix-web/serve.go → cmd/searchix-web/serve.go
@@ -10,6 +10,7 @@ "syscall" "github.com/Southclaws/fault" "github.com/Southclaws/fault/fmsg" + "golang.org/x/term" "alin.ovh/searchix/internal/file" "alin.ovh/searchix/internal/importer"@@ -23,7 +24,12 @@ type ServeOptions struct{} func (opts *ServeOptions) Execute(_ []string) (err error) { - ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + signals := []os.Signal{os.Interrupt, syscall.SIGTERM} + if term.IsTerminal(int(os.Stdout.Fd())) { + signals = append(signals, syscall.SIGHUP) + } + + ctx, cancel := signal.NotifyContext(context.Background(), signals...) defer cancel() root, err := file.CreateAndOpenRoot(cfg.DataPath)
M go.mod → go.mod
@@ -25,6 +25,7 @@ github.com/yuin/goldmark v1.7.12 go.etcd.io/bbolt v1.4.2 go.uber.org/zap v1.27.0 golang.org/x/net v0.41.0 + golang.org/x/term v0.34.0 modernc.org/sqlite v1.38.0 )@@ -64,7 +65,7 @@ github.com/sykesm/zap-logfmt v0.0.4 // indirect github.com/thessem/zap-prettyconsole v0.5.2 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 // indirect - golang.org/x/sys v0.34.0 // indirect + golang.org/x/sys v0.35.0 // indirect golang.org/x/text v0.26.0 // indirect google.golang.org/protobuf v1.36.6 // indirect modernc.org/libc v1.65.10 // indirect
M go.sum → go.sum
@@ -213,9 +213,11 @@ golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4= +golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
M gomod2nix.toml → gomod2nix.toml
@@ -173,8 +173,11 @@ [mod."golang.org/x/net"] version = "v0.41.0" hash = "sha256-6/pi8rNmGvBFzkJQXkXkMfL1Bjydhg3BgAMYDyQ/Uvg=" [mod."golang.org/x/sys"] + version = "v0.35.0" + hash = "sha256-ZKM8pesQE6NAFZeKQ84oPn5JMhGr8g4TSwLYAsHMGSI=" + [mod."golang.org/x/term"] version = "v0.34.0" - hash = "sha256-5rZ7p8IaGli5X1sJbfIKOcOEwY4c0yQhinJPh2EtK50=" + hash = "sha256-faLolF6EUSSaC0ZwRiKH5JF/TmtcMQ+m+RWWl6Pk1PU=" [mod."golang.org/x/text"] version = "v0.26.0" hash = "sha256-N+27nBCyGvje0yCTlUzZoVZ0LRxx4AJ+eBlrFQVRlFQ="