@@ -136,6 +136,9 @@ |
||
136 | 136 | $job->setNextRun($newTime); |
137 | 137 | } |
138 | 138 | |
139 | + /** |
|
140 | + * @param string $output |
|
141 | + */ |
|
139 | 142 | protected function recordJobResult(EntityManager $em, CronJob $job, $timeTaken, $output, $resultCode) |
140 | 143 | { |
141 | 144 | // Create a new CronJobResult |
@@ -16,8 +16,8 @@ |
||
16 | 16 | protected function configure() |
17 | 17 | { |
18 | 18 | $this->setName('cron:run') |
19 | - ->setDescription('Runs any currently schedule cron jobs') |
|
20 | - ->addArgument('job', InputArgument::OPTIONAL, 'Run only this job (if enabled)'); |
|
19 | + ->setDescription('Runs any currently schedule cron jobs') |
|
20 | + ->addArgument('job', InputArgument::OPTIONAL, 'Run only this job (if enabled)'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $em->flush(); |
54 | 54 | |
55 | 55 | $end = microtime(true); |
56 | - $duration = sprintf('%0.2f', $end - $start); |
|
56 | + $duration = sprintf('%0.2f', $end-$start); |
|
57 | 57 | $output->writeln("Cron run completed in $duration seconds"); |
58 | 58 | } |
59 | 59 | |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | $statusStr = 'failed'; |
101 | 101 | } |
102 | 102 | |
103 | - $durationStr = sprintf('%0.2f', $jobEnd - $jobStart); |
|
103 | + $durationStr = sprintf('%0.2f', $jobEnd-$jobStart); |
|
104 | 104 | $output->writeln("$statusStr in $durationStr seconds"); |
105 | 105 | |
106 | 106 | // Record the result |
107 | - $this->recordJobResult($em, $job, $jobEnd - $jobStart, $jobOutput->getOutput(), $returnCode); |
|
107 | + $this->recordJobResult($em, $job, $jobEnd-$jobStart, $jobOutput->getOutput(), $returnCode); |
|
108 | 108 | |
109 | 109 | // And update the job with it's next scheduled time |
110 | 110 | $newTime = new \DateTime(); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * Set nextRun |
138 | 138 | * |
139 | - * @param datetime $nextRun |
|
139 | + * @param \DateTime $nextRun |
|
140 | 140 | */ |
141 | 141 | public function setNextRun($nextRun) |
142 | 142 | { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * Add results |
158 | 158 | * |
159 | - * @param Alpixel\Bundle\CronBundle\Entity\CronJobResult $results |
|
159 | + * @param CronJobResult $results |
|
160 | 160 | */ |
161 | 161 | public function addCronJobResult(\Alpixel\Bundle\CronBundle\Entity\CronJobResult $results) |
162 | 162 | { |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | /** |
177 | 177 | * Set mostRecentRun |
178 | 178 | * |
179 | - * @param Alpixel\Bundle\CronBundle\Entity\CronJobResult $mostRecentRun |
|
179 | + * @param CronJobResult $mostRecentRun |
|
180 | 180 | */ |
181 | 181 | public function setMostRecentRun(\Alpixel\Bundle\CronBundle\Entity\CronJobResult $mostRecentRun) |
182 | 182 | { |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | /** |
187 | 187 | * Get mostRecentRun |
188 | 188 | * |
189 | - * @return Alpixel\Bundle\CronBundle\Entity\CronJobResult |
|
189 | + * @return CronJobResult |
|
190 | 190 | */ |
191 | 191 | public function getMostRecentRun() |
192 | 192 | { |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * Set job |
152 | 152 | * |
153 | - * @param Alpixel\Bundle\CronBundle\Entity\CronJob $job |
|
153 | + * @param CronJob $job |
|
154 | 154 | */ |
155 | 155 | public function setJob(\Alpixel\Bundle\CronBundle\Entity\CronJob $job) |
156 | 156 | { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | /** |
161 | 161 | * Get job |
162 | 162 | * |
163 | - * @return Alpixel\Bundle\CronBundle\Entity\CronJob |
|
163 | + * @return CronJob |
|
164 | 164 | */ |
165 | 165 | public function getJob() |
166 | 166 | { |
@@ -14,8 +14,8 @@ |
||
14 | 14 | protected function configure() |
15 | 15 | { |
16 | 16 | $this->setName('cron:status') |
17 | - ->setDescription('Displays the current status of cron jobs') |
|
18 | - ->addArgument('job', InputArgument::OPTIONAL, 'Show information for only this job'); |
|
17 | + ->setDescription('Displays the current status of cron jobs') |
|
18 | + ->addArgument('job', InputArgument::OPTIONAL, 'Show information for only this job'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -12,8 +12,8 @@ |
||
12 | 12 | protected function configure() |
13 | 13 | { |
14 | 14 | $this->setName('cron:enable-job') |
15 | - ->setDescription('Enables a cron job') |
|
16 | - ->addArgument('job', InputArgument::REQUIRED, 'Name of the job to enable'); |
|
15 | + ->setDescription('Enables a cron job') |
|
16 | + ->addArgument('job', InputArgument::REQUIRED, 'Name of the job to enable'); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -13,8 +13,8 @@ |
||
13 | 13 | protected function configure() |
14 | 14 | { |
15 | 15 | $this->setName('cron:pruneLogs') |
16 | - ->setDescription('Prunes the logs for each cron job, leaving only recent failures and the most recent success') |
|
17 | - ->addArgument('job', InputArgument::OPTIONAL, 'Operate only on this job'); |
|
16 | + ->setDescription('Prunes the logs for each cron job, leaving only recent failures and the most recent success') |
|
17 | + ->addArgument('job', InputArgument::OPTIONAL, 'Operate only on this job'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -16,9 +16,9 @@ |
||
16 | 16 | protected function configure() |
17 | 17 | { |
18 | 18 | $this->setName('cron:scan') |
19 | - ->setDescription('Scans for any new or deleted cron jobs') |
|
20 | - ->addOption('keep-deleted', 'k', InputOption::VALUE_NONE, 'If set, deleted cron jobs will not be removed') |
|
21 | - ->addOption('default-disabled', 'd', InputOption::VALUE_NONE, 'If set, new jobs will be disabled by default'); |
|
19 | + ->setDescription('Scans for any new or deleted cron jobs') |
|
20 | + ->addOption('keep-deleted', 'k', InputOption::VALUE_NONE, 'If set, deleted cron jobs will not be removed') |
|
21 | + ->addOption('default-disabled', 'd', InputOption::VALUE_NONE, 'If set, new jobs will be disabled by default'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -13,8 +13,8 @@ |
||
13 | 13 | protected function configure() |
14 | 14 | { |
15 | 15 | $this->setName('cron:disable-job') |
16 | - ->setDescription('Disables a cron job') |
|
17 | - ->addArgument('job', InputArgument::REQUIRED, 'Name of the job to disable'); |
|
16 | + ->setDescription('Disables a cron job') |
|
17 | + ->addArgument('job', InputArgument::REQUIRED, 'Name of the job to disable'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -9,8 +9,8 @@ |
||
9 | 9 | public function getKnownJobs() |
10 | 10 | { |
11 | 11 | $data = $this->getEntityManager() |
12 | - ->createQuery('SELECT job.command FROM CronBundle:CronJob job') |
|
13 | - ->getScalarResult(); |
|
12 | + ->createQuery('SELECT job.command FROM CronBundle:CronJob job') |
|
13 | + ->getScalarResult(); |
|
14 | 14 | $toRet = []; |
15 | 15 | foreach ($data as $datum) { |
16 | 16 | $toRet[] = $datum['command']; |