@@ -21,9 +21,9 @@ |
||
21 | 21 | return $this->name; |
22 | 22 | } |
23 | 23 | |
24 | - public function getJobs($start=0, $stop=-1) |
|
24 | + public function getJobs($start = 0, $stop = -1) |
|
25 | 25 | { |
26 | - $jobs = \Resque::redis()->lrange('queue:' . $this->name, $start, $stop); |
|
26 | + $jobs = \Resque::redis()->lrange('queue:'.$this->name, $start, $stop); |
|
27 | 27 | |
28 | 28 | $result = array(); |
29 | 29 | foreach ($jobs as $job) { |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | public function getQueues() |
30 | 30 | { |
31 | - return \array_map(function ($queue) { |
|
31 | + return \array_map(function($queue) { |
|
32 | 32 | return new Queue($queue); |
33 | 33 | }, $this->worker->queues()); |
34 | 34 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | ->arrayNode('auto_retry') |
40 | 40 | ->beforeNormalization() |
41 | 41 | ->ifArray() |
42 | - ->then(function ($var) { |
|
42 | + ->then(function($var) { |
|
43 | 43 | if (array_key_exists(0, $var)) { |
44 | 44 | return array($var); |
45 | 45 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | $resque = $this->getContainer()->get('resque'); |
24 | 24 | |
25 | 25 | $queue = $input->getArgument('queue'); |
26 | - $count=$resque->clearQueue($queue); |
|
26 | + $count = $resque->clearQueue($queue); |
|
27 | 27 | |
28 | 28 | $output->writeln('Cleared queue '.$queue.' - removed '.$count.' entries'); |
29 | 29 |
@@ -100,15 +100,15 @@ |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | |
103 | - // In windows: When you pass an environment to CMD it replaces the old environment |
|
104 | - // That means we create a lot of problems with respect to user accounts and missing vars |
|
105 | - // this is a workaround where we add the vars to the existing environment. |
|
106 | - if (defined('PHP_WINDOWS_VERSION_BUILD')) { |
|
107 | - foreach($env as $key => $value) { |
|
108 | - putenv($key."=". $value); |
|
109 | - } |
|
110 | - $env = null; |
|
111 | - } |
|
103 | + // In windows: When you pass an environment to CMD it replaces the old environment |
|
104 | + // That means we create a lot of problems with respect to user accounts and missing vars |
|
105 | + // this is a workaround where we add the vars to the existing environment. |
|
106 | + if (defined('PHP_WINDOWS_VERSION_BUILD')) { |
|
107 | + foreach($env as $key => $value) { |
|
108 | + putenv($key."=". $value); |
|
109 | + } |
|
110 | + $env = null; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | $process = new Process($workerCommand, null, $env, null, null); |
114 | 114 |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | // That means we create a lot of problems with respect to user accounts and missing vars |
105 | 105 | // this is a workaround where we add the vars to the existing environment. |
106 | 106 | if (defined('PHP_WINDOWS_VERSION_BUILD')) { |
107 | - foreach($env as $key => $value) { |
|
108 | - putenv($key."=". $value); |
|
107 | + foreach ($env as $key => $value) { |
|
108 | + putenv($key."=".$value); |
|
109 | 109 | } |
110 | 110 | $env = null; |
111 | 111 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // if foreground, we redirect output |
120 | 120 | if ($input->getOption('foreground')) { |
121 | - $process->run(function ($type, $buffer) use ($output) { |
|
121 | + $process->run(function($type, $buffer) use ($output) { |
|
122 | 122 | $output->write($buffer); |
123 | 123 | }); |
124 | 124 | } |
@@ -72,17 +72,17 @@ |
||
72 | 72 | $workerCommand = 'nohup ' . $workerCommand . ' > ' . $logFile .' 2>&1 & echo $!'; |
73 | 73 | } |
74 | 74 | |
75 | - // In windows: When you pass an environment to CMD it replaces the old environment |
|
76 | - // That means we create a lot of problems with respect to user accounts and missing vars |
|
77 | - // this is a workaround where we add the vars to the existing environment. |
|
78 | - if (defined('PHP_WINDOWS_VERSION_BUILD')) |
|
79 | - { |
|
80 | - foreach($env as $key => $value) |
|
81 | - { |
|
82 | - putenv($key."=". $value); |
|
83 | - } |
|
84 | - $env = null; |
|
85 | - } |
|
75 | + // In windows: When you pass an environment to CMD it replaces the old environment |
|
76 | + // That means we create a lot of problems with respect to user accounts and missing vars |
|
77 | + // this is a workaround where we add the vars to the existing environment. |
|
78 | + if (defined('PHP_WINDOWS_VERSION_BUILD')) |
|
79 | + { |
|
80 | + foreach($env as $key => $value) |
|
81 | + { |
|
82 | + putenv($key."=". $value); |
|
83 | + } |
|
84 | + $env = null; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | 88 | $process = new Process($workerCommand, null, $env, null, null); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | protected function execute(InputInterface $input, OutputInterface $output) |
25 | 25 | { |
26 | - $pidFile=$this->getContainer()->get('kernel')->getCacheDir().'/resque_scheduledworker.pid'; |
|
26 | + $pidFile = $this->getContainer()->get('kernel')->getCacheDir().'/resque_scheduledworker.pid'; |
|
27 | 27 | if (file_exists($pidFile) && !$input->getOption('force')) { |
28 | 28 | throw new \Exception('PID file exists - use --force to override'); |
29 | 29 | } |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | if (!$input->getOption('foreground')) { |
69 | 69 | $logFile = $this->getContainer()->getParameter( |
70 | 70 | 'kernel.logs_dir' |
71 | - ) . '/resque-scheduler_' . $this->getContainer()->getParameter('kernel.environment') . '.log'; |
|
72 | - $workerCommand = 'nohup ' . $workerCommand . ' > ' . $logFile .' 2>&1 & echo $!'; |
|
71 | + ).'/resque-scheduler_'.$this->getContainer()->getParameter('kernel.environment').'.log'; |
|
72 | + $workerCommand = 'nohup '.$workerCommand.' > '.$logFile.' 2>&1 & echo $!'; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // In windows: When you pass an environment to CMD it replaces the old environment |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | // this is a workaround where we add the vars to the existing environment. |
78 | 78 | if (defined('PHP_WINDOWS_VERSION_BUILD')) |
79 | 79 | { |
80 | - foreach($env as $key => $value) |
|
80 | + foreach ($env as $key => $value) |
|
81 | 81 | { |
82 | - putenv($key."=". $value); |
|
82 | + putenv($key."=".$value); |
|
83 | 83 | } |
84 | 84 | $env = null; |
85 | 85 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $output->writeln(\sprintf('Starting worker <info>%s</info>', $process->getCommandLine())); |
91 | 91 | |
92 | 92 | if ($input->getOption('foreground')) { |
93 | - $process->run(function ($type, $buffer) use ($output) { |
|
93 | + $process->run(function($type, $buffer) use ($output) { |
|
94 | 94 | $output->write($buffer); |
95 | 95 | }); |
96 | 96 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $hostname = php_uname('n'); |
105 | 105 | } |
106 | 106 | $output->writeln(\sprintf('<info>Worker started</info> %s:%s', $hostname, $pid)); |
107 | - file_put_contents($pidFile,$pid); |
|
107 | + file_put_contents($pidFile, $pid); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
@@ -20,18 +20,18 @@ |
||
20 | 20 | |
21 | 21 | protected function execute(InputInterface $input, OutputInterface $output) |
22 | 22 | { |
23 | - $pidFile=$this->getContainer()->get('kernel')->getCacheDir().'/resque_scheduledworker.pid'; |
|
23 | + $pidFile = $this->getContainer()->get('kernel')->getCacheDir().'/resque_scheduledworker.pid'; |
|
24 | 24 | if (!file_exists($pidFile)) { |
25 | 25 | $output->writeln('No PID file found'); |
26 | 26 | |
27 | 27 | return -1; |
28 | 28 | } |
29 | 29 | |
30 | - $pid=file_get_contents($pidFile); |
|
30 | + $pid = file_get_contents($pidFile); |
|
31 | 31 | |
32 | 32 | $output->writeln('Killing process '.$pid); |
33 | 33 | |
34 | - \posix_kill($pid,SIGTERM); |
|
34 | + \posix_kill($pid, SIGTERM); |
|
35 | 35 | |
36 | 36 | unlink($pidFile); |
37 | 37 |
@@ -6,7 +6,9 @@ |
||
6 | 6 | use Symfony\Component\Console\Input\InputInterface; |
7 | 7 | use Symfony\Component\Console\Output\OutputInterface; |
8 | 8 | |
9 | -if (!defined('SIGTERM')) define('SIGTERM', 15); |
|
9 | +if (!defined('SIGTERM')) { |
|
10 | + define('SIGTERM', 15); |
|
11 | +} |
|
10 | 12 | |
11 | 13 | class StopScheduledWorkerCommand extends ContainerAwareCommand |
12 | 14 | { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | $this->attachRetryStrategy($job); |
132 | 132 | |
133 | - return \ResqueScheduler::removeDelayed($job->queue, \get_class($job),$job->args); |
|
133 | + return \ResqueScheduler::removeDelayed($job->queue, \get_class($job), $job->args); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | public function removeFromTimestamp($at, Job $job) |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | public function getQueues() |
148 | 148 | { |
149 | - return \array_map(function ($queue) { |
|
149 | + return \array_map(function($queue) { |
|
150 | 150 | return new Queue($queue); |
151 | 151 | }, \Resque::queues()); |
152 | 152 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | public function getWorkers() |
164 | 164 | { |
165 | - return \array_map(function ($worker) { |
|
165 | + return \array_map(function($worker) { |
|
166 | 166 | return new Worker($worker); |
167 | 167 | }, \Resque_Worker::all()); |
168 | 168 | } |
@@ -188,12 +188,12 @@ discard block |
||
188 | 188 | |
189 | 189 | public function getDelayedJobTimestamps() |
190 | 190 | { |
191 | - $timestamps= \Resque::redis()->zrange('delayed_queue_schedule', 0, -1); |
|
191 | + $timestamps = \Resque::redis()->zrange('delayed_queue_schedule', 0, -1); |
|
192 | 192 | |
193 | 193 | //TODO: find a more efficient way to do this |
194 | - $out=array(); |
|
194 | + $out = array(); |
|
195 | 195 | foreach ($timestamps as $timestamp) { |
196 | - $out[]=array($timestamp,\Resque::redis()->llen('delayed:'.$timestamp)); |
|
196 | + $out[] = array($timestamp, \Resque::redis()->llen('delayed:'.$timestamp)); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | return $out; |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | |
202 | 202 | public function getFirstDelayedJobTimestamp() |
203 | 203 | { |
204 | - $timestamps=$this->getDelayedJobTimestamps(); |
|
205 | - if (count($timestamps)>0) { |
|
204 | + $timestamps = $this->getDelayedJobTimestamps(); |
|
205 | + if (count($timestamps) > 0) { |
|
206 | 206 | return $timestamps[0]; |
207 | 207 | } |
208 | 208 | |
209 | - return array(null,0); |
|
209 | + return array(null, 0); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | public function getNumberOfDelayedJobs() |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | |
217 | 217 | public function getJobsForTimestamp($timestamp) |
218 | 218 | { |
219 | - $jobs= \Resque::redis()->lrange('delayed:'.$timestamp,0, -1); |
|
220 | - $out=array(); |
|
219 | + $jobs = \Resque::redis()->lrange('delayed:'.$timestamp, 0, -1); |
|
220 | + $out = array(); |
|
221 | 221 | foreach ($jobs as $job) { |
222 | - $out[]=json_decode($job, true); |
|
222 | + $out[] = json_decode($job, true); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | return $out; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function clearQueue($queue) |
233 | 233 | { |
234 | - $length=\Resque::redis()->llen('queue:'.$queue); |
|
234 | + $length = \Resque::redis()->llen('queue:'.$queue); |
|
235 | 235 | \Resque::redis()->del('queue:'.$queue); |
236 | 236 | |
237 | 237 | return $length; |