Fix signal handling for termination, proper engine cleanup

This commit is contained in:
lash 2025-01-22 19:08:57 +00:00
parent 1e495763f5
commit 99d03e3bc9
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746

View File

@ -141,11 +141,14 @@ func main() {
signal.Notify(cint, os.Interrupt, syscall.SIGINT) signal.Notify(cint, os.Interrupt, syscall.SIGINT)
signal.Notify(cterm, os.Interrupt, syscall.SIGTERM) signal.Notify(cterm, os.Interrupt, syscall.SIGTERM)
go func() { go func() {
var s os.Signal
select { select {
case _ = <-cint: case s = <-cterm:
case _ = <-cterm: case s = <-cint:
} }
menuStorageService.Close(ctx) logg.InfoCtxf(ctx, "stopping on signal", "sig", s)
en.Finish(ctx)
os.Exit(0)
}() }()
err = engine.Loop(ctx, en, os.Stdin, os.Stdout, nil) err = engine.Loop(ctx, en, os.Stdin, os.Stdout, nil)