@@ -13,8 +13,8 @@ |
||
13 | 13 | protected function configure() |
14 | 14 | { |
15 | 15 | $this->setName("cron:enable-job") |
16 | - ->setDescription("Enables a cron job") |
|
17 | - ->addArgument("job", InputArgument::REQUIRED, "Name of the job to enable"); |
|
16 | + ->setDescription("Enables a cron job") |
|
17 | + ->addArgument("job", InputArgument::REQUIRED, "Name of the job to enable"); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -17,8 +17,8 @@ |
||
17 | 17 | protected function configure() |
18 | 18 | { |
19 | 19 | $this->setName("cron:status") |
20 | - ->setDescription("Displays the current status of cron jobs") |
|
21 | - ->addArgument("job", InputArgument::OPTIONAL, "Show information for only this job"); |
|
20 | + ->setDescription("Displays the current status of cron jobs") |
|
21 | + ->addArgument("job", InputArgument::OPTIONAL, "Show information for only this job"); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -32,14 +32,12 @@ discard block |
||
32 | 32 | try |
33 | 33 | { |
34 | 34 | $cronJobs = array($jobRepo->findOneByCommand($jobName)); |
35 | - } |
|
36 | - catch(\Exception $e) |
|
35 | + } catch(\Exception $e) |
|
37 | 36 | { |
38 | 37 | $output->writeln("Couldn't find a job by the name of $jobName"); |
39 | 38 | return CronJobResult::FAILED; |
40 | 39 | } |
41 | - } |
|
42 | - else |
|
40 | + } else |
|
43 | 41 | { |
44 | 42 | $cronJobs = $em->getRepository('CronBundle:CronJob')->findAll(); |
45 | 43 | } |
@@ -56,16 +54,14 @@ discard block |
||
56 | 54 | if(!$cronJob->getEnabled()) |
57 | 55 | { |
58 | 56 | $output->writeln(" Not scheduled"); |
59 | - } |
|
60 | - else |
|
57 | + } else |
|
61 | 58 | { |
62 | 59 | $output->write(" Scheduled for: "); |
63 | 60 | $now = new \DateTime(); |
64 | 61 | if($cronJob->getNextRun() <= $now) |
65 | 62 | { |
66 | 63 | $output->writeln("Next run"); |
67 | - } |
|
68 | - else |
|
64 | + } else |
|
69 | 65 | { |
70 | 66 | $output->writeln(strftime("%c", $cronJob->getNextRun()->getTimestamp())); |
71 | 67 | } |
@@ -86,8 +82,7 @@ discard block |
||
86 | 82 | break; |
87 | 83 | } |
88 | 84 | $output->writeln(" Last run was: $status"); |
89 | - } |
|
90 | - else |
|
85 | + } else |
|
91 | 86 | { |
92 | 87 | $output->writeln(" This job has not yet been run"); |
93 | 88 | } |
@@ -23,9 +23,9 @@ |
||
23 | 23 | protected function configure() |
24 | 24 | { |
25 | 25 | $this->setName("cron:scan") |
26 | - ->setDescription("Scans for any new or deleted cron jobs") |
|
27 | - ->addOption('keep-deleted', 'k', InputOption::VALUE_NONE, 'If set, deleted cron jobs will not be removed') |
|
28 | - ->addOption('default-disabled', 'd', InputOption::VALUE_NONE, 'If set, new jobs will be disabled by default'); |
|
26 | + ->setDescription("Scans for any new or deleted cron jobs") |
|
27 | + ->addOption('keep-deleted', 'k', InputOption::VALUE_NONE, 'If set, deleted cron jobs will not be removed') |
|
28 | + ->addOption('default-disabled', 'd', InputOption::VALUE_NONE, 'If set, new jobs will be disabled by default'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -68,8 +68,7 @@ |
||
68 | 68 | $currentJob->setNextRun($newTime); |
69 | 69 | $output->writeln("Updated interval for $job to {$anno->value}"); |
70 | 70 | } |
71 | - } |
|
72 | - else |
|
71 | + } else |
|
73 | 72 | { |
74 | 73 | $this->newJobFound($em, $output, $command, $anno, $defaultDisabled); |
75 | 74 | } |
@@ -16,8 +16,8 @@ |
||
16 | 16 | protected function configure() |
17 | 17 | { |
18 | 18 | $this->setName("cron:pruneLogs") |
19 | - ->setDescription("Prunes the logs for each cron job, leaving only recent failures and the most recent success") |
|
20 | - ->addArgument('job', InputArgument::OPTIONAL, 'Operate only on this job'); |
|
19 | + ->setDescription("Prunes the logs for each cron job, leaving only recent failures and the most recent success") |
|
20 | + ->addArgument('job', InputArgument::OPTIONAL, 'Operate only on this job'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -28,8 +28,7 @@ discard block |
||
28 | 28 | if($job) |
29 | 29 | { |
30 | 30 | $output->writeln("Pruning logs for cron job $job"); |
31 | - } |
|
32 | - else |
|
31 | + } else |
|
33 | 32 | { |
34 | 33 | $output->writeln("Pruning logs for all cron jobs"); |
35 | 34 | } |
@@ -44,8 +43,7 @@ discard block |
||
44 | 43 | } |
45 | 44 | |
46 | 45 | $em->getRepository('CronBundle:CronJobResult')->deleteOldLogs($jobObj); |
47 | - } |
|
48 | - else |
|
46 | + } else |
|
49 | 47 | { |
50 | 48 | $em->getRepository('CronBundle:CronJobResult')->deleteOldLogs(); |
51 | 49 | } |
@@ -21,8 +21,8 @@ |
||
21 | 21 | protected function configure() |
22 | 22 | { |
23 | 23 | $this->setName("cron:run") |
24 | - ->setDescription("Runs any currently schedule cron jobs") |
|
25 | - ->addArgument("job", InputArgument::OPTIONAL, "Run only this job (if enabled)"); |
|
24 | + ->setDescription("Runs any currently schedule cron jobs") |
|
25 | + ->addArgument("job", InputArgument::OPTIONAL, "Run only this job (if enabled)"); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -41,14 +41,12 @@ discard block |
||
41 | 41 | { |
42 | 42 | $jobsToRun = array($jobObj); |
43 | 43 | } |
44 | - } |
|
45 | - catch(\Exception $e) |
|
44 | + } catch(\Exception $e) |
|
46 | 45 | { |
47 | 46 | $output->writeln("Couldn't find a job by the name of $jobName"); |
48 | 47 | return CronJobResult::FAILED; |
49 | 48 | } |
50 | - } |
|
51 | - else |
|
49 | + } else |
|
52 | 50 | { |
53 | 51 | $jobsToRun = $jobRepo->findDueTasks(); |
54 | 52 | } |
@@ -76,8 +74,7 @@ discard block |
||
76 | 74 | try |
77 | 75 | { |
78 | 76 | $commandToRun = $this->getApplication()->get($job->getCommand()); |
79 | - } |
|
80 | - catch(InvalidArgumentException $ex) |
|
77 | + } catch(InvalidArgumentException $ex) |
|
81 | 78 | { |
82 | 79 | $output->writeln(" skipped (command no longer exists)"); |
83 | 80 | $this->recordJobResult($em, $job, 0, "Command no longer exists", CronJobResult::SKIPPED); |
@@ -93,8 +90,7 @@ discard block |
||
93 | 90 | try |
94 | 91 | { |
95 | 92 | $returnCode = $commandToRun->execute($emptyInput, $jobOutput); |
96 | - } |
|
97 | - catch(\Exception $ex) |
|
93 | + } catch(\Exception $ex) |
|
98 | 94 | { |
99 | 95 | $returnCode = CronJobResult::FAILED; |
100 | 96 | $jobOutput->writeln(""); |
@@ -114,12 +110,10 @@ discard block |
||
114 | 110 | if($returnCode == CronJobResult::SKIPPED) |
115 | 111 | { |
116 | 112 | $statusStr = "skipped"; |
117 | - } |
|
118 | - elseif($returnCode == CronJobResult::SUCCEEDED) |
|
113 | + } elseif($returnCode == CronJobResult::SUCCEEDED) |
|
119 | 114 | { |
120 | 115 | $statusStr = "succeeded"; |
121 | - } |
|
122 | - elseif($returnCode == CronJobResult::FAILED) |
|
116 | + } elseif($returnCode == CronJobResult::FAILED) |
|
123 | 117 | { |
124 | 118 | $statusStr = "failed"; |
125 | 119 | } |
@@ -15,8 +15,8 @@ |
||
15 | 15 | protected function configure() |
16 | 16 | { |
17 | 17 | $this->setName("cron:disable-job") |
18 | - ->setDescription("Disables a cron job") |
|
19 | - ->addArgument("job", InputArgument::REQUIRED, "Name of the job to disable"); |
|
18 | + ->setDescription("Disables a cron job") |
|
19 | + ->addArgument("job", InputArgument::REQUIRED, "Name of the job to disable"); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | protected function execute(InputInterface $input, OutputInterface $output) |
@@ -12,6 +12,6 @@ |
||
12 | 12 | ->getEntityManager() |
13 | 13 | ->createQuery("DELETE CronBundle:CronJobResult result") |
14 | 14 | ->getResult() |
15 | - ; |
|
15 | + ; |
|
16 | 16 | } |
17 | 17 | } |
@@ -7,8 +7,8 @@ |
||
7 | 7 | public function getKnownJobs() |
8 | 8 | { |
9 | 9 | $data = $this->getEntityManager() |
10 | - ->createQuery("SELECT job.command FROM CronBundle:CronJob job") |
|
11 | - ->getScalarResult(); |
|
10 | + ->createQuery("SELECT job.command FROM CronBundle:CronJob job") |
|
11 | + ->getScalarResult(); |
|
12 | 12 | $toRet = array(); |
13 | 13 | foreach($data as $datum) |
14 | 14 | { |