From 7b9c3cf531934e446e540920a0fb27f0b7f86dc7 Mon Sep 17 00:00:00 2001 From: yanghao05 Date: Mon, 10 Jul 2023 20:09:05 +0800 Subject: [PATCH] fix quit issues --- container/container.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/container/container.go b/container/container.go index e1cd767..1982018 100644 --- a/container/container.go +++ b/container/container.go @@ -18,15 +18,18 @@ var ( ) func init() { + closeable = make([]func(), 0) if err := Container.Provide(func() context.Context { ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) + go func() { + <-ctx.Done() + Close() + }() Cancel = cancel return ctx }); err != nil { log.Fatal(err) } - - closeable = make([]func(), 0) } func AddCloseAble(c func()) {