all repos — searchix @ 15a5b3210a073c83dbd1ace8969df83c53dac755

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: listen for SIGHUP if running in a terminal

Alan Pearce
commit

15a5b3210a073c83dbd1ace8969df83c53dac755

parent

8df14f9bef62ef8ea37afb49e04a2873e914e45c

1 file changed, 7 insertions(+), 1 deletion(-)

changed files
M cmd/searchix-web/serve.gocmd/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)