func Stop(q *skynet.Query) { cl := client.NewClient(&config) for _, instance := range filterDaemon(q.FindInstances()) { cdaemon := daemon.GetDaemonForService(cl, instance) in := daemon.StopSubServiceRequest{UUID: instance.Config.UUID} out, err := cdaemon.StopSubService(in) if err != nil { if strings.HasPrefix(err.Error(), "No such service UUID") { // no daemon on the service's machine, shut it down directly AdminStop(q) } else { fmt.Println(err) } } else { stopTemplate.Execute(os.Stdout, out) } } }
func Restart(q *skynet.Query) { cl := client.NewClient(&config) for _, instance := range filterDaemon(q.FindInstances()) { cdaemon := daemon.GetDaemonForService(cl, instance) in := daemon.RestartSubServiceRequest{UUID: instance.Config.UUID} out, err := cdaemon.RestartSubService(in) if err != nil { if strings.HasPrefix(err.Error(), "No such service UUID") { // Commented out for now, we need to determine if we want to try to restart an unmanaged instance, and support it // no daemon on the service's machine, shut it down directly //AdminStop(q) } else { fmt.Println(err) } } else { restartTemplate.Execute(os.Stdout, out) } } }