fix quit issues

This commit is contained in:
yanghao05
2023-07-10 20:09:05 +08:00
parent c4ec53b4d0
commit 7b9c3cf531

View File

@@ -18,15 +18,18 @@ var (
) )
func init() { func init() {
closeable = make([]func(), 0)
if err := Container.Provide(func() context.Context { if err := Container.Provide(func() context.Context {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
<-ctx.Done()
Close()
}()
Cancel = cancel Cancel = cancel
return ctx return ctx
}); err != nil { }); err != nil {
log.Fatal(err) log.Fatal(err)
} }
closeable = make([]func(), 0)
} }
func AddCloseAble(c func()) { func AddCloseAble(c func()) {