/** * Create a new ScheduledCommand in database * * @param $name * @param $command * @param $arguments * @param $cronExpression * @param $logFile * @param $priority * @param $lastExecution * @param bool $locked * @param bool $disabled * @param bool $executeNow * @param integer $lastReturnCode */ protected function createScheduledCommand($name, $command, $arguments, $cronExpression, $logFile, $priority, $lastExecution, $locked = false, $disabled = false, $executeNow = false, $lastReturnCode = null) { $scheduledCommand = new ScheduledCommand(); $scheduledCommand->setName($name)->setCommand($command)->setArguments($arguments)->setCronExpression($cronExpression)->setLogFile($logFile)->setPriority($priority)->setLastExecution($lastExecution)->setLocked($locked)->setDisabled($disabled)->setLastReturnCode($lastReturnCode)->setExecuteImmediately($executeNow); $this->manager->persist($scheduledCommand); $this->manager->flush(); }
/** * check if command has failed (returncode != 0) or locken and timeout exceeded * * @param ScheduledCommand $command * * @return bool */ protected function checkCommandFailed(ScheduledCommand $command) { $executionTime = $command->getLastExecution(); $executionTimestamp = $executionTime->getTimestamp(); $timedOut = $executionTimestamp + $this->timeoutValue < $this->now; return $command->getLastReturnCode() != 0 || $command->getLocked() && ($this->timeoutValue === false || $timedOut); }