kill and start correctly

This commit is contained in:
A.Unger
2021-03-10 17:02:06 +01:00
parent 4ee52cc9cd
commit d3af1eacfb
+12 -5
View File
@@ -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.