From 1316dd3ffc4824147b8af90cc81fd6e711cc7742 Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Fri, 8 Nov 2024 15:50:28 +1000 Subject: [PATCH] fix proxy Director usage and close on shutdown --- internal/machine/machine.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/machine/machine.go b/internal/machine/machine.go index ccccf1df..595a9d7e 100644 --- a/internal/machine/machine.go +++ b/internal/machine/machine.go @@ -148,7 +148,7 @@ func NewMachine(config *Config) (*Machine, error) { dockerServer := docker.NewServer(dockerCli) // Init a local gRPC proxy server that proxies requests to the local or remote machine API servers. - proxyDirector := apiproxy.NewDirector(config.MachineSockPath) + proxyDirector := apiproxy.NewDirector(config.MachineSockPath, APIPort) localProxyServer := grpc.NewServer( grpc.ForceServerCodecV2(proxy.Codec()), grpc.UnknownServiceHandler( @@ -329,6 +329,8 @@ func (m *Machine) Run(ctx context.Context) error { slog.Info("Stopping local API proxy server.") // TODO: implement timeout for graceful shutdown. m.localProxyServer.GracefulStop() + // Close the proxy director to close all backend connections. + m.proxyDirector.Close() slog.Info("Local API proxy server stopped.") return nil },