From d3af1eacfb678ed318305909e8dd8772088d97b2 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 10 Mar 2021 17:02:06 +0100 Subject: [PATCH] kill and start correctly --- ocis/pkg/runtime/service/service.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 0b9db575f..eb7e85741 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -188,14 +188,21 @@ func Start(o ...Option) error { // Start indicates the Service Controller to start a new supervised service as an OS thread. func (s *Service) Start(name string, reply *int) error { - if _, ok := s.ServicesRegistry[name]; !ok { - *reply = 1 + swap := deepcopy.Copy(s.cfg) + if _, ok := s.ServicesRegistry[name]; ok { + *reply = 0 + s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](s.context, swap.(*ociscfg.Config)))) return nil } - swap := deepcopy.Copy(s.cfg) - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](s.context, swap.(*ociscfg.Config)))) + + if _, ok := s.Delayed[name]; ok { + *reply = 0 + s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](s.context, swap.(*ociscfg.Config)))) + return nil + } + *reply = 0 - return nil + return fmt.Errorf("cannot start service %s: unknown service", name) } // List running processes for the Service Controller.