本文整理匯總了Golang中github.com/catalyzeio/cli/lib/jobs.IJobs.List方法的典型用法代碼示例。如果您正苦於以下問題:Golang IJobs.List方法的具體用法?Golang IJobs.List怎麽用?Golang IJobs.List使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/catalyzeio/cli/lib/jobs.IJobs
的用法示例。
在下文中一共展示了IJobs.List方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CmdStop
// CmdStop stops all instances of a given service. All workers and rake tasks will also be stopped
// if applicable.
func CmdStop(svcName string, is IServices, ij jobs.IJobs, ip prompts.IPrompts) error {
err := ip.YesNo(fmt.Sprintf("Are you sure you want to stop %s? This will stop all instances of the service, all workers, all rake tasks, and all currently open consoles. (y/n) ", svcName))
if err != nil {
return err
}
service, err := is.RetrieveByLabel(svcName)
if err != nil {
return err
}
if service == nil {
return fmt.Errorf("Could not find a service with the label \"%s\". You can list services with the \"catalyze services list\" command.", svcName)
}
if !service.Redeployable {
return fmt.Errorf("This service cannot be stopped. Please contact Catalyze Support at [email protected] if you need the \"%s\" service stopped.", svcName)
}
page := 0
pageSize := 100
for {
jobs, err := ij.List(service.ID, page, pageSize)
if err != nil {
return err
}
for _, job := range *jobs {
if job.Status != "scheduled" && job.Status != "queued" && job.Status != "started" && job.Status != "running" && job.Status != "waiting" {
logrus.Debugf("Skipping %s job (%s)", job.Status, job.ID)
continue
}
logrus.Debugf("Deleting %s job (%s) on service %s", job.Type, job.ID, service.ID)
err = ij.Delete(job.ID, service.ID)
if err != nil {
return err
}
}
if len(*jobs) < pageSize {
break
}
page++
}
logrus.Printf("Successfully stopped %s. Run \"catalyze redeploy %s\" to start this service again.", svcName, svcName)
return nil
}