made minimalLB+CCM

This commit is contained in:
2026-04-10 20:25:58 +02:00
parent 7bb0698f77
commit fc89c098b6
5 changed files with 108 additions and 25 deletions
+20 -6
View File
@@ -266,21 +266,28 @@ func (srv *Server) Run() error {
}
sigs := make(chan os.Signal, 1)
done := make(chan error, 1)
done := make(chan error, 3)
// Run service
startService := func(svc *service.Service, done chan error) {
startRPCService := func(svc *service.Service, done chan error) {
srv.log.Infof("Run rpc service")
err = svc.Run()
if err != nil {
srv.log.Errorf("Service error: %v", err)
srv.log.Errorf("RPC service error: %v", err)
done <- err
}
}
go startService(srv.svc, done)
go startRPCService(srv.svc, done)
// Run controller
srv.log.Infof("Run controller")
go srv.cont.Run()
startContService := func(cont *control.Controller, done chan error) {
srv.log.Infof("Run controller")
err = cont.Run()
if err != nil {
srv.log.Errorf("Controller service error: %v", err)
done <- err
}
}
go startContService(srv.cont, done)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
var signal os.Signal
@@ -289,6 +296,13 @@ func (srv *Server) Run() error {
srv.log.Infof("Services stopped by signal: %v", signal)
srv.cancel()
srv.svc.Stop()
srv.cont.Stop()
srv.wg.Wait()
case err := <-done:
srv.log.Infof("Services stopped by error: %v", err)
srv.cancel()
srv.svc.Stop()
srv.cont.Stop()
srv.wg.Wait()
}
return err