daemon: Split host operations into ManagedService

This commit is contained in:
世界
2026-08-30 17:41:41 +08:00
parent 5d7a0d92c6
commit 2bd6a233dc
11 changed files with 1016 additions and 831 deletions
+12
View File
@@ -20,12 +20,15 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
type CommandServer struct {
*daemon.StartedService
managedService *daemon.ManagedService
handler CommandServerHandler
platformInterface PlatformInterface
platformWrapper *platformInterfaceWrapper
@@ -71,6 +74,10 @@ func NewCommandServer(handler CommandServerHandler, platformInterface PlatformIn
// GroupID: sGroupID,
// SystemProxyEnabled: false,
})
server.managedService = daemon.NewManagedService(daemon.ManagedServiceOptions{
Handler: (*platformHandler)(server),
Debug: sDebug,
})
return server, nil
}
@@ -155,6 +162,11 @@ func (s *CommandServer) Start() error {
}
s.grpcServer = grpc.NewServer(serverOptions...)
daemon.RegisterStartedServiceServer(s.grpcServer, s.StartedService)
daemon.RegisterManagedServiceServer(s.grpcServer, s.managedService)
healthServer := health.NewServer()
healthServer.SetServingStatus(daemon.StartedService_ServiceDesc.ServiceName, grpc_health_v1.HealthCheckResponse_SERVING)
healthServer.SetServingStatus(daemon.ManagedService_ServiceDesc.ServiceName, grpc_health_v1.HealthCheckResponse_SERVING)
grpc_health_v1.RegisterHealthServer(s.grpcServer, healthServer)
go s.grpcServer.Serve(listener)
return nil
}