mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 12:03:33 +00:00
fix proxy Director usage and close on shutdown
This commit is contained in:
@@ -148,7 +148,7 @@ func NewMachine(config *Config) (*Machine, error) {
|
|||||||
dockerServer := docker.NewServer(dockerCli)
|
dockerServer := docker.NewServer(dockerCli)
|
||||||
|
|
||||||
// Init a local gRPC proxy server that proxies requests to the local or remote machine API servers.
|
// 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(
|
localProxyServer := grpc.NewServer(
|
||||||
grpc.ForceServerCodecV2(proxy.Codec()),
|
grpc.ForceServerCodecV2(proxy.Codec()),
|
||||||
grpc.UnknownServiceHandler(
|
grpc.UnknownServiceHandler(
|
||||||
@@ -329,6 +329,8 @@ func (m *Machine) Run(ctx context.Context) error {
|
|||||||
slog.Info("Stopping local API proxy server.")
|
slog.Info("Stopping local API proxy server.")
|
||||||
// TODO: implement timeout for graceful shutdown.
|
// TODO: implement timeout for graceful shutdown.
|
||||||
m.localProxyServer.GracefulStop()
|
m.localProxyServer.GracefulStop()
|
||||||
|
// Close the proxy director to close all backend connections.
|
||||||
|
m.proxyDirector.Close()
|
||||||
slog.Info("Local API proxy server stopped.")
|
slog.Info("Local API proxy server stopped.")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user