diff --git a/cmd/server/main.go b/cmd/server/main.go index 5df6342cf..0d8cdecec 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -284,7 +284,11 @@ func main() { homeCfg.DisableClusterDiscovery = true } homeClient = home.New(homeCfg) - defer homeClient.Close() + defer func() { + if homeClient != nil { + homeClient.Close() + } + }() ctxHomeConfig, cancelHomeConfig := context.WithTimeout(context.Background(), 30*time.Second) raw, errGetConfig := homeClient.GetConfig(ctxHomeConfig) @@ -622,6 +626,12 @@ func main() { return } } + if homeClient != nil { + // The bootstrap client is not owned by the runtime service. Close it after + // the final startup report so it cannot retain an idle RESP connection. + homeClient.Close() + homeClient = nil + } if pluginHost.HasTriggeredCommandLineFlags() { if exitCode, handled := pluginHost.ExecuteCommandLine(context.Background(), os.Args[0], os.Args[1:], configFilePath, flag.CommandLine); handled { if exitCode != 0 {