feat: listen for SIGHUP if running in a terminal
1 file changed, 7 insertions(+), 1 deletion(-)
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)