@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(empty($argv[1])) { |
|
2 | +if (empty($argv[1])) { |
|
3 | 3 | die('Specify the ID of a job to monitor the status of.'); |
4 | 4 | } |
5 | 5 | |
@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | //Resque::setBackend('redis://user:[email protected]:3432/2'); |
13 | 13 | |
14 | 14 | $status = new Resque_Job_Status($argv[1]); |
15 | -if(!$status->isTracking()) { |
|
15 | +if (!$status->isTracking()) { |
|
16 | 16 | die("Resque is not tracking the status of this job.\n"); |
17 | 17 | } |
18 | 18 | |
19 | -echo "Tracking status of ".$argv[1].". Press [break] to stop.\n\n"; |
|
20 | -while(true) { |
|
21 | - fwrite(STDOUT, "Status of ".$argv[1]." is: ".$status->get()."\n"); |
|
19 | +echo "Tracking status of " . $argv[1] . ". Press [break] to stop.\n\n"; |
|
20 | +while (true) { |
|
21 | + fwrite(STDOUT, "Status of " . $argv[1] . " is: " . $status->get() . "\n"); |
|
22 | 22 | sleep(1); |
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(empty($argv[1])) { |
|
2 | +if (empty($argv[1])) { |
|
3 | 3 | die('Specify the name of a job to add. e.g, php queue.php PHP_Job'); |
4 | 4 | } |
5 | 5 | |
@@ -23,4 +23,4 @@ discard block |
||
23 | 23 | $jobId = Resque::enqueue($argv[1], $argv[2], $args, true); |
24 | 24 | } |
25 | 25 | |
26 | -echo "Queued job ".$jobId."\n\n"; |
|
26 | +echo "Queued job " . $jobId . "\n\n"; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public static function fork() |
78 | 78 | { |
79 | - if(!function_exists('pcntl_fork')) { |
|
79 | + if (!function_exists('pcntl_fork')) { |
|
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | self::$redis = null; |
86 | 86 | |
87 | 87 | $pid = pcntl_fork(); |
88 | - if($pid === -1) { |
|
88 | + if ($pid === -1) { |
|
89 | 89 | throw new RuntimeException('Unable to fork child worker.'); |
90 | 90 | } |
91 | 91 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | { |
125 | 125 | $item = self::redis()->lpop('queue:' . $queue); |
126 | 126 | |
127 | - if(!$item) { |
|
127 | + if (!$item) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public static function dequeue($queue, $items = Array()) |
142 | 142 | { |
143 | - if(count($items) > 0) { |
|
143 | + if (count($items) > 0) { |
|
144 | 144 | return self::removeItems($queue, $items); |
145 | 145 | } else { |
146 | 146 | return self::removeList($queue); |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | public static function blpop(array $queues, $timeout) |
172 | 172 | { |
173 | 173 | $list = array(); |
174 | - foreach($queues AS $queue) { |
|
174 | + foreach ($queues AS $queue) { |
|
175 | 175 | $list[] = 'queue:' . $queue; |
176 | 176 | } |
177 | 177 | |
178 | 178 | $item = self::redis()->blpop($list, (int)$timeout); |
179 | 179 | |
180 | - if(!$item) { |
|
180 | + if (!$item) { |
|
181 | 181 | return; |
182 | 182 | } |
183 | 183 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | try { |
229 | 229 | Resque_Event::trigger('beforeEnqueue', $hookParams); |
230 | 230 | } |
231 | - catch(Resque_Job_DontCreate $e) { |
|
231 | + catch (Resque_Job_DontCreate $e) { |
|
232 | 232 | return false; |
233 | 233 | } |
234 | 234 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | public static function queues() |
258 | 258 | { |
259 | 259 | $queues = self::redis()->smembers('queues'); |
260 | - if(!is_array($queues)) { |
|
260 | + if (!is_array($queues)) { |
|
261 | 261 | $queues = array(); |
262 | 262 | } |
263 | 263 | return $queues; |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | private static function removeItems($queue, $items = Array()) |
279 | 279 | { |
280 | 280 | $counter = 0; |
281 | - $originalQueue = 'queue:'. $queue; |
|
282 | - $tempQueue = $originalQueue. ':temp:'. time(); |
|
283 | - $requeueQueue = $tempQueue. ':requeue'; |
|
281 | + $originalQueue = 'queue:' . $queue; |
|
282 | + $tempQueue = $originalQueue . ':temp:' . time(); |
|
283 | + $requeueQueue = $tempQueue . ':requeue'; |
|
284 | 284 | |
285 | 285 | // move each item from original queue to temp queue and process it |
286 | 286 | $finished = false; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $string = self::redis()->rpoplpush($originalQueue, self::redis()->getPrefix() . $tempQueue); |
289 | 289 | |
290 | 290 | if (!empty($string)) { |
291 | - if(self::matchItem($string, $items)) { |
|
291 | + if (self::matchItem($string, $items)) { |
|
292 | 292 | self::redis()->rpop($tempQueue); |
293 | 293 | $counter++; |
294 | 294 | } else { |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | // move back from temp queue to original queue |
303 | 303 | $finished = false; |
304 | 304 | while (!$finished) { |
305 | - $string = self::redis()->rpoplpush($requeueQueue, self::redis()->getPrefix() .$originalQueue); |
|
305 | + $string = self::redis()->rpoplpush($requeueQueue, self::redis()->getPrefix() . $originalQueue); |
|
306 | 306 | if (empty($string)) { |
307 | 307 | $finished = true; |
308 | 308 | } |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | { |
330 | 330 | $decoded = json_decode($string, true); |
331 | 331 | |
332 | - foreach($items as $key => $val) { |
|
332 | + foreach ($items as $key => $val) { |
|
333 | 333 | # class name only ex: item[0] = ['class'] |
334 | 334 | if (is_numeric($key)) { |
335 | - if($decoded['class'] == $val) { |
|
335 | + if ($decoded['class'] == $val) { |
|
336 | 336 | return true; |
337 | 337 | } |
338 | 338 | # class name with args , example: item[0] = ['class' => {'foo' => 1, 'bar' => 2}] |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $id = Resque::generateJobId(); |
64 | 64 | } |
65 | 65 | |
66 | - if($args !== null && !is_array($args)) { |
|
66 | + if ($args !== null && !is_array($args)) { |
|
67 | 67 | throw new InvalidArgumentException( |
68 | 68 | 'Supplied $args must be an array.' |
69 | 69 | ); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | 'queue_time' => microtime(true), |
76 | 76 | )); |
77 | 77 | |
78 | - if($monitor) { |
|
78 | + if ($monitor) { |
|
79 | 79 | Resque_Job_Status::create($id); |
80 | 80 | } |
81 | 81 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public static function reserve($queue) |
93 | 93 | { |
94 | 94 | $payload = Resque::pop($queue); |
95 | - if(!is_array($payload)) { |
|
95 | + if (!is_array($payload)) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | $item = Resque::blpop($queues, $timeout); |
113 | 113 | |
114 | - if(!is_array($item)) { |
|
114 | + if (!is_array($item)) { |
|
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function updateStatus($status) |
127 | 127 | { |
128 | - if(empty($this->payload['id'])) { |
|
128 | + if (empty($this->payload['id'])) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
@@ -187,20 +187,20 @@ discard block |
||
187 | 187 | Resque_Event::trigger('beforePerform', $this); |
188 | 188 | |
189 | 189 | $instance = $this->getInstance(); |
190 | - if(method_exists($instance, 'setUp')) { |
|
190 | + if (method_exists($instance, 'setUp')) { |
|
191 | 191 | $instance->setUp(); |
192 | 192 | } |
193 | 193 | |
194 | 194 | $instance->perform(); |
195 | 195 | |
196 | - if(method_exists($instance, 'tearDown')) { |
|
196 | + if (method_exists($instance, 'tearDown')) { |
|
197 | 197 | $instance->tearDown(); |
198 | 198 | } |
199 | 199 | |
200 | 200 | Resque_Event::trigger('afterPerform', $this); |
201 | 201 | } |
202 | 202 | // beforePerform/setUp have said don't perform this job. Return. |
203 | - catch(Resque_Job_DontPerform $e) { |
|
203 | + catch (Resque_Job_DontPerform $e) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | { |
239 | 239 | $status = new Resque_Job_Status($this->payload['id']); |
240 | 240 | $monitor = false; |
241 | - if($status->isTracking()) { |
|
241 | + if ($status->isTracking()) { |
|
242 | 242 | $monitor = true; |
243 | 243 | } |
244 | 244 | |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | public function __toString() |
254 | 254 | { |
255 | 255 | $name = array( |
256 | - 'Job{' . $this->queue .'}' |
|
256 | + 'Job{' . $this->queue . '}' |
|
257 | 257 | ); |
258 | - if(!empty($this->payload['id'])) { |
|
258 | + if (!empty($this->payload['id'])) { |
|
259 | 259 | $name[] = 'ID: ' . $this->payload['id']; |
260 | 260 | } |
261 | 261 | $name[] = $this->payload['class']; |
262 | - if(!empty($this->payload['args'])) { |
|
262 | + if (!empty($this->payload['args'])) { |
|
263 | 263 | $name[] = json_encode($this->payload['args']); |
264 | 264 | } |
265 | 265 | return '(' . implode(' | ', $name) . ')'; |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function isTracking() |
68 | 68 | { |
69 | - if($this->isTracking === false) { |
|
69 | + if ($this->isTracking === false) { |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
73 | - if(!Resque::redis()->exists((string)$this)) { |
|
73 | + if (!Resque::redis()->exists((string)$this)) { |
|
74 | 74 | $this->isTracking = false; |
75 | 75 | return false; |
76 | 76 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function update($status) |
88 | 88 | { |
89 | - if(!$this->isTracking()) { |
|
89 | + if (!$this->isTracking()) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | Resque::redis()->set((string)$this, json_encode($statusPacket)); |
98 | 98 | |
99 | 99 | // Expire the status for completed jobs after 24 hours |
100 | - if(in_array($status, self::$completeStatuses)) { |
|
100 | + if (in_array($status, self::$completeStatuses)) { |
|
101 | 101 | Resque::redis()->expire((string)$this, 86400); |
102 | 102 | } |
103 | 103 | } |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function get() |
112 | 112 | { |
113 | - if(!$this->isTracking()) { |
|
113 | + if (!$this->isTracking()) { |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
117 | 117 | $statusPacket = json_decode(Resque::redis()->get((string)$this), true); |
118 | - if(!$statusPacket) { |
|
118 | + if (!$statusPacket) { |
|
119 | 119 | return false; |
120 | 120 | } |
121 | 121 |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | $this->driver = new Credis_Client($host, $port, $timeout, $persistent); |
132 | 132 | $this->driver->setMaxConnectRetries($maxRetries); |
133 | - if ($password){ |
|
133 | + if ($password) { |
|
134 | 134 | $this->driver->auth($password); |
135 | 135 | } |
136 | 136 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $this->driver->select($database); |
146 | 146 | } |
147 | 147 | } |
148 | - catch(CredisException $e) { |
|
148 | + catch (CredisException $e) { |
|
149 | 149 | throw new Resque_RedisException('Error communicating with Redis: ' . $e->getMessage(), 0, $e); |
150 | 150 | } |
151 | 151 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | // Use a sensible default for an empty DNS string |
171 | 171 | $dsn = 'redis://' . self::DEFAULT_HOST; |
172 | 172 | } |
173 | - if(substr($dsn, 0, 7) === 'unix://') { |
|
173 | + if (substr($dsn, 0, 7) === 'unix://') { |
|
174 | 174 | return array( |
175 | 175 | $dsn, |
176 | 176 | null, |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | |
185 | 185 | // Check the URI scheme |
186 | 186 | $validSchemes = array('redis', 'tcp'); |
187 | - if (isset($parts['scheme']) && ! in_array($parts['scheme'], $validSchemes)) { |
|
187 | + if (isset($parts['scheme']) && !in_array($parts['scheme'], $validSchemes)) { |
|
188 | 188 | throw new \InvalidArgumentException("Invalid DSN. Supported schemes are " . implode(', ', $validSchemes)); |
189 | 189 | } |
190 | 190 | |
191 | 191 | // Allow simple 'hostname' format, which `parse_url` treats as a path, not host. |
192 | - if ( ! isset($parts['host']) && isset($parts['path'])) { |
|
192 | + if (!isset($parts['host']) && isset($parts['path'])) { |
|
193 | 193 | $parts['host'] = $parts['path']; |
194 | 194 | unset($parts['path']); |
195 | 195 | } |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | |
261 | 261 | public static function removePrefix($string) |
262 | 262 | { |
263 | - $prefix=self::getPrefix(); |
|
263 | + $prefix = self::getPrefix(); |
|
264 | 264 | |
265 | 265 | if (substr($string, 0, strlen($prefix)) == $prefix) { |
266 | - $string = substr($string, strlen($prefix), strlen($string) ); |
|
266 | + $string = substr($string, strlen($prefix), strlen($string)); |
|
267 | 267 | } |
268 | 268 | return $string; |
269 | 269 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | public static function getBackend() |
37 | 37 | { |
38 | - if(self::$backend === null) { |
|
38 | + if (self::$backend === null) { |
|
39 | 39 | self::$backend = 'Resque_Failure_Redis'; |
40 | 40 | } |
41 | 41 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(ticks = 1); |
|
2 | +declare(ticks=1); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Resque worker that handles checking queues for jobs, fetching them |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | { |
72 | 72 | $this->logger = new Resque_Log(); |
73 | 73 | |
74 | - if(!is_array($queues)) { |
|
74 | + if (!is_array($queues)) { |
|
75 | 75 | $queues = array($queues); |
76 | 76 | } |
77 | 77 | |
78 | 78 | $this->queues = $queues; |
79 | 79 | $this->hostname = php_uname('n'); |
80 | 80 | |
81 | - $this->id = $this->hostname . ':'.getmypid() . ':' . implode(',', $this->queues); |
|
81 | + $this->id = $this->hostname . ':' . getmypid() . ':' . implode(',', $this->queues); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | public static function all() |
89 | 89 | { |
90 | 90 | $workers = Resque::redis()->smembers('workers'); |
91 | - if(!is_array($workers)) { |
|
91 | + if (!is_array($workers)) { |
|
92 | 92 | $workers = array(); |
93 | 93 | } |
94 | 94 | |
95 | 95 | $instances = array(); |
96 | - foreach($workers as $workerId) { |
|
96 | + foreach ($workers as $workerId) { |
|
97 | 97 | $instances[] = self::find($workerId); |
98 | 98 | } |
99 | 99 | return $instances; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public static function find($workerId) |
120 | 120 | { |
121 | - if(!self::exists($workerId) || false === strpos($workerId, ":")) { |
|
121 | + if (!self::exists($workerId) || false === strpos($workerId, ":")) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | $this->updateProcLine('Starting'); |
153 | 153 | $this->startup(); |
154 | 154 | |
155 | - while(true) { |
|
156 | - if($this->shutdown) { |
|
155 | + while (true) { |
|
156 | + if ($this->shutdown) { |
|
157 | 157 | break; |
158 | 158 | } |
159 | 159 | |
160 | 160 | // Attempt to find and reserve a job |
161 | 161 | $job = false; |
162 | - if(!$this->paused) { |
|
163 | - if($blocking === true) { |
|
162 | + if (!$this->paused) { |
|
163 | + if ($blocking === true) { |
|
164 | 164 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Starting blocking with timeout of {interval}', array('interval' => $interval)); |
165 | 165 | $this->updateProcLine('Waiting for ' . implode(',', $this->queues) . ' with blocking timeout ' . $interval); |
166 | 166 | } else { |
@@ -172,17 +172,17 @@ discard block |
||
172 | 172 | |
173 | 173 | pcntl_signal_dispatch(); |
174 | 174 | |
175 | - if(!$job) { |
|
175 | + if (!$job) { |
|
176 | 176 | // For an interval of 0, break now - helps with unit testing etc |
177 | - if($interval == 0) { |
|
177 | + if ($interval == 0) { |
|
178 | 178 | break; |
179 | 179 | } |
180 | 180 | |
181 | - if($blocking === false) |
|
181 | + if ($blocking === false) |
|
182 | 182 | { |
183 | 183 | // If no job was found, we sleep for $interval before continuing and checking again |
184 | 184 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Sleeping for {interval}', array('interval' => $interval)); |
185 | - if($this->paused) { |
|
185 | + if ($this->paused) { |
|
186 | 186 | $this->updateProcLine('Paused'); |
187 | 187 | } |
188 | 188 | else { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if($this->child > 0) { |
|
215 | + if ($this->child > 0) { |
|
216 | 216 | // Parent process, sit and wait |
217 | 217 | $status = 'Forked ' . $this->child . ' at ' . strftime('%F %T'); |
218 | 218 | $this->updateProcLine($status); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | Resque_Event::trigger('afterFork', $job); |
257 | 257 | $job->perform(); |
258 | 258 | } |
259 | - catch(Exception $e) { |
|
259 | + catch (Exception $e) { |
|
260 | 260 | $this->logger->log(Psr\Log\LogLevel::CRITICAL, '{job} has failed {stack}', array('job' => $job, 'stack' => $e)); |
261 | 261 | $job->fail($e); |
262 | 262 | return; |
@@ -280,21 +280,21 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | $queues = $this->queues(); |
283 | - if(!is_array($queues)) { |
|
283 | + if (!is_array($queues)) { |
|
284 | 284 | return; |
285 | 285 | } |
286 | 286 | |
287 | - if($blocking === true) { |
|
287 | + if ($blocking === true) { |
|
288 | 288 | $job = Resque_Job::reserveBlocking($queues, $timeout); |
289 | - if($job) { |
|
289 | + if ($job) { |
|
290 | 290 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Found job on {queue}', array('queue' => $job->queue)); |
291 | 291 | return $job; |
292 | 292 | } |
293 | 293 | } else { |
294 | - foreach($queues as $queue) { |
|
294 | + foreach ($queues as $queue) { |
|
295 | 295 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Checking {queue} for jobs', array('queue' => $queue)); |
296 | 296 | $job = Resque_Job::reserve($queue); |
297 | - if($job) { |
|
297 | + if ($job) { |
|
298 | 298 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Found job on {queue}', array('queue' => $job->queue)); |
299 | 299 | return $job; |
300 | 300 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function queues($fetch = true) |
319 | 319 | { |
320 | - if(!in_array('*', $this->queues) || $fetch == false) { |
|
320 | + if (!in_array('*', $this->queues) || $fetch == false) { |
|
321 | 321 | return $this->queues; |
322 | 322 | } |
323 | 323 | |
@@ -347,10 +347,10 @@ discard block |
||
347 | 347 | private function updateProcLine($status) |
348 | 348 | { |
349 | 349 | $processTitle = 'resque-' . Resque::VERSION . ': ' . $status; |
350 | - if(function_exists('cli_set_process_title') && PHP_OS !== 'Darwin') { |
|
350 | + if (function_exists('cli_set_process_title') && PHP_OS !== 'Darwin') { |
|
351 | 351 | cli_set_process_title($processTitle); |
352 | 352 | } |
353 | - else if(function_exists('setproctitle')) { |
|
353 | + else if (function_exists('setproctitle')) { |
|
354 | 354 | setproctitle($processTitle); |
355 | 355 | } |
356 | 356 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | */ |
366 | 366 | private function registerSigHandlers() |
367 | 367 | { |
368 | - if(!function_exists('pcntl_signal')) { |
|
368 | + if (!function_exists('pcntl_signal')) { |
|
369 | 369 | return; |
370 | 370 | } |
371 | 371 | |
@@ -423,13 +423,13 @@ discard block |
||
423 | 423 | */ |
424 | 424 | public function killChild() |
425 | 425 | { |
426 | - if(!$this->child) { |
|
426 | + if (!$this->child) { |
|
427 | 427 | $this->logger->log(Psr\Log\LogLevel::DEBUG, 'No child to kill.'); |
428 | 428 | return; |
429 | 429 | } |
430 | 430 | |
431 | 431 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Killing child at {child}', array('child' => $this->child)); |
432 | - if(exec('ps -o pid,state -p ' . $this->child, $output, $returnCode) && $returnCode != 1) { |
|
432 | + if (exec('ps -o pid,state -p ' . $this->child, $output, $returnCode) && $returnCode != 1) { |
|
433 | 433 | $this->logger->log(Psr\Log\LogLevel::DEBUG, 'Child {child} found, killing.', array('child' => $this->child)); |
434 | 434 | posix_kill($this->child, SIGKILL); |
435 | 435 | $this->child = null; |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | { |
453 | 453 | $workerPids = $this->workerPids(); |
454 | 454 | $workers = self::all(); |
455 | - foreach($workers as $worker) { |
|
455 | + foreach ($workers as $worker) { |
|
456 | 456 | if (is_object($worker)) { |
457 | 457 | list($host, $pid, $queues) = explode(':', (string)$worker, 3); |
458 | - if($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) { |
|
458 | + if ($host != $this->hostname || in_array($pid, $workerPids) || $pid == getmypid()) { |
|
459 | 459 | continue; |
460 | 460 | } |
461 | 461 | $this->logger->log(Psr\Log\LogLevel::INFO, 'Pruning dead worker: {worker}', array('worker' => (string)$worker)); |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | { |
475 | 475 | $pids = array(); |
476 | 476 | exec('ps -A -o pid,command | grep [r]esque', $cmdOutput); |
477 | - foreach($cmdOutput as $line) { |
|
477 | + foreach ($cmdOutput as $line) { |
|
478 | 478 | list($pids[],) = explode(' ', trim($line), 2); |
479 | 479 | } |
480 | 480 | return $pids; |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | */ |
495 | 495 | public function unregisterWorker() |
496 | 496 | { |
497 | - if(is_object($this->currentJob)) { |
|
497 | + if (is_object($this->currentJob)) { |
|
498 | 498 | $this->currentJob->fail(new Resque_Job_DirtyExitException); |
499 | 499 | } |
500 | 500 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | public function job() |
555 | 555 | { |
556 | 556 | $job = Resque::redis()->get('worker:' . $this); |
557 | - if(!$job) { |
|
557 | + if (!$job) { |
|
558 | 558 | return array(); |
559 | 559 | } |
560 | 560 | else { |