From 57818f82fc52593b5d382edcff453562de9f28b4 Mon Sep 17 00:00:00 2001 From: truthhun <1272881215@qq.com> Date: Sun, 5 Mar 2023 14:57:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E5=90=AC=E6=8C=87=E5=AE=9A=E9=80=80?= =?UTF-8?q?=E5=87=BA=E4=BF=A1=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/serve.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/serve.go b/cmd/serve.go index c422960..e54d30d 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -22,6 +22,7 @@ import ( "moredoc/util/command" "os" "os/signal" + "syscall" "github.com/spf13/cobra" ) @@ -37,7 +38,8 @@ var serveCmd = &cobra.Command{ util.BuildAt = BuildAt c := make(chan os.Signal, 1) - signal.Notify(c) + // 监听退出信号 + signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) go func() { //阻塞直至有信号传入 s := <-c