From c900e6b4c36226cfff8c4b29db190f4cb4f9b570 Mon Sep 17 00:00:00 2001 From: appleboy Date: Sun, 16 Mar 2025 14:20:55 +0800 Subject: [PATCH] feat: add context management and cancellation handling in `Execute` function - Import the `context` package - Add context cancellation handling with log message and return in `Execute` function Signed-off-by: appleboy --- cmd/cmd.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/cmd.go b/cmd/cmd.go index 299d0a6..0b51c08 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -1,6 +1,7 @@ package cmd import ( + "context" "flag" "gitea.com/gitea/gitea-mcp/operation" @@ -57,6 +58,10 @@ func init() { func Execute(version string) { defer log.Default().Sync() if err := operation.Run(transport, version); err != nil { + if err == context.Canceled { + log.Info("Server shutdown due to context cancellation") + return + } log.Fatalf("Run Gitea MCP Server Error: %v", err) } }