本文整理匯總了Golang中github.com/echocat/caretakerd/service.Execution.Service方法的典型用法代碼示例。如果您正苦於以下問題:Golang Execution.Service方法的具體用法?Golang Execution.Service怎麽用?Golang Execution.Service使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/echocat/caretakerd/service.Execution
的用法示例。
在下文中一共展示了Execution.Service方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: delayedStartIfNeeded
func (instance *Execution) delayedStartIfNeeded(target *service.Execution, currentRun int) bool {
config := target.Service().Config()
if currentRun == 1 {
return instance.delayedStartIfNeededFor(target, config.StartDelayInSeconds, "Wait %d seconds before starting...")
}
return instance.delayedStartIfNeededFor(target, config.RestartDelayInSeconds, "Wait %d seconds before restarting...")
}
示例2: doUnregisterExecution
func (instance *Execution) doUnregisterExecution(target *service.Execution) {
instance.doWLock()
defer instance.doWUnlock()
delete(instance.executions, target.Service())
delete(instance.restartRequests, target.Service())
instance.wg.Done()
}
示例3: delayedStartIfNeededFor
func (instance *Execution) delayedStartIfNeededFor(target *service.Execution, delayInSeconds values.NonNegativeInteger, messagePattern string) bool {
s := target.Service()
if s.Config().StartDelayInSeconds > 0 {
s.Logger().Log(logger.Debug, messagePattern, delayInSeconds)
return target.SyncGroup().Sleep(time.Duration(delayInSeconds)*time.Second) == nil
}
return true
}
示例4: doAfterExecution
func (instance *Execution) doAfterExecution(target *service.Execution, exitCode values.ExitCode, err error) {
defer instance.doUnregisterExecution(target)
if target.Service().Config().Type == service.Master {
instance.masterExitCode = &exitCode
instance.masterError = err
instance.stopOthers()
}
}
示例5: recreateExecution
func (instance *Execution) recreateExecution(target *service.Execution) (*service.Execution, error) {
instance.doWLock()
defer instance.doWUnlock()
s := target.Service()
newTarget, err := s.NewExecution(instance.executable.KeyStore())
if err != nil {
delete(instance.executions, s)
} else {
instance.executions[s] = newTarget
}
delete(instance.restartRequests, s)
return newTarget, err
}
示例6: checkAfterExecutionStates
func (instance *Execution) checkAfterExecutionStates(target *service.Execution, exitCode values.ExitCode, err error) (doRestart bool, respectDelay bool) {
if _, ok := err.(service.StoppedOrKilledError); ok {
doRestart = false
} else if _, ok := err.(service.UnrecoverableError); ok {
doRestart = target.Service().Config().CronExpression.IsEnabled() && instance.masterExitCode == nil
} else if instance.checkRestartRequestedAndClean(target.Service()) {
doRestart = true
respectDelay = false
} else if target.Service().Config().SuccessExitCodes.Contains(exitCode) {
doRestart = (target.Service().Config().CronExpression.IsEnabled() && instance.masterExitCode == nil) || target.Service().Config().AutoRestart.OnSuccess()
} else {
doRestart = target.Service().Config().AutoRestart.OnFailures()
respectDelay = true
}
return doRestart, respectDelay
}
示例7: isAlreadyStopRequested
func (instance *Execution) isAlreadyStopRequested(target *service.Execution) bool {
instance.doRLock()
defer instance.doRUnlock()
stopRequested, ok := instance.stopRequests[target.Service()]
return ok && stopRequested
}