From c1204e32d55051901f4ffe42118345e5905a7c8d Mon Sep 17 00:00:00 2001 From: icey-yu <1186114839@qq.com> Date: Wed, 25 Dec 2024 12:08:29 +0800 Subject: [PATCH] fix: config --- internal/api/init.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/api/init.go b/internal/api/init.go index 33652aca5..0a122b901 100644 --- a/internal/api/init.go +++ b/internal/api/init.go @@ -151,8 +151,9 @@ func Start(ctx context.Context, index int, config *Config) error { sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGTERM) - ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) shutdown := func() error { + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() err := server.Shutdown(ctx) if err != nil { return errs.WrapMsg(err, "shutdown err") @@ -160,7 +161,6 @@ func Start(ctx context.Context, index int, config *Config) error { return nil } disetcd.RegisterShutDown(shutdown) - defer cancel() select { case <-sigs: program.SIGTERMExit()