@@ -42,7 +42,7 @@ |
||
42 | 42 | */ |
43 | 43 | private function context() |
44 | 44 | { |
45 | - $pid = getmypid(); |
|
45 | + $pid = getmypid(); |
|
46 | 46 | switch ($pid) { |
47 | 47 | case $this->ownerPid: |
48 | 48 | $role = 'owner'; |
@@ -23,7 +23,7 @@ |
||
23 | 23 | $this->params['id'] = spl_object_hash($this); |
24 | 24 | if (!$this->params['driver']) { |
25 | 25 | $this->params['driver'] = new FlatFileDriver( |
26 | - sys_get_temp_dir() . DIRECTORY_SEPARATOR . $this->params['id'] |
|
26 | + sys_get_temp_dir().DIRECTORY_SEPARATOR.$this->params['id'] |
|
27 | 27 | ); |
28 | 28 | } |
29 | 29 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(ticks = 1); |
|
2 | +declare(ticks=1); |
|
3 | 3 | namespace Ackintosh\Snidel\Fork; |
4 | 4 | |
5 | 5 | use Ackintosh\Snidel\ActiveWorkerSet; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | try { |
116 | 116 | $this->master = $this->pcntl->fork(); |
117 | 117 | } catch (\RuntimeException $e) { |
118 | - $message = 'failed to fork master: ' . $e->getMessage(); |
|
118 | + $message = 'failed to fork master: '.$e->getMessage(); |
|
119 | 119 | $this->log->error($message); |
120 | 120 | throw new \RuntimeException($message); |
121 | 121 | } |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | |
125 | 125 | if (getmypid() === $this->config->get('ownerPid')) { |
126 | 126 | // owner |
127 | - $this->log->info('pid: ' . getmypid()); |
|
128 | - $this->resultQueue = $this->factory->create('result'); |
|
127 | + $this->log->info('pid: '.getmypid()); |
|
128 | + $this->resultQueue = $this->factory->create('result'); |
|
129 | 129 | |
130 | 130 | return $this->master; |
131 | 131 | } else { |
@@ -133,17 +133,17 @@ discard block |
||
133 | 133 | // covered by SnidelTest via master process |
134 | 134 | // master |
135 | 135 | $activeWorkerSet = new ActiveWorkerSet(); |
136 | - $this->log->info('pid: ' . $this->master->getPid()); |
|
136 | + $this->log->info('pid: '.$this->master->getPid()); |
|
137 | 137 | |
138 | 138 | foreach ($this->signals as $sig) { |
139 | - $this->pcntl->signal($sig, function ($sig) use ($activeWorkerSet) { |
|
139 | + $this->pcntl->signal($sig, function($sig) use ($activeWorkerSet) { |
|
140 | 140 | $this->receivedSignal = $sig; |
141 | - $this->log->info('received signal: ' . $sig); |
|
141 | + $this->log->info('received signal: '.$sig); |
|
142 | 142 | |
143 | 143 | if ($activeWorkerSet->count() === 0) { |
144 | 144 | $this->log->info('no worker is active.'); |
145 | 145 | } else { |
146 | - $this->log->info('------> sending signal to workers. signal: ' . $sig); |
|
146 | + $this->log->info('------> sending signal to workers. signal: '.$sig); |
|
147 | 147 | $activeWorkerSet->terminate($sig); |
148 | 148 | $this->log->info('<------ sent signal'); |
149 | 149 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | }); |
152 | 152 | } |
153 | 153 | |
154 | - $concurrency = (int)$this->config->get('concurrency'); |
|
154 | + $concurrency = (int) $this->config->get('concurrency'); |
|
155 | 155 | for ($i = 0; $i < $concurrency; $i++) { |
156 | 156 | $activeWorkerSet->add($this->forkWorker()); |
157 | 157 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | try { |
182 | 182 | $process = $this->pcntl->fork(); |
183 | 183 | } catch (\RuntimeException $e) { |
184 | - $message = 'failed to fork worker: ' . $e->getMessage(); |
|
184 | + $message = 'failed to fork worker: '.$e->getMessage(); |
|
185 | 185 | $this->log->error($message); |
186 | 186 | throw new \RuntimeException($message); |
187 | 187 | } |
@@ -190,22 +190,22 @@ discard block |
||
190 | 190 | |
191 | 191 | if (getmypid() === $this->master->getPid()) { |
192 | 192 | // master |
193 | - $this->log->info('forked worker. pid: ' . $worker->getPid()); |
|
193 | + $this->log->info('forked worker. pid: '.$worker->getPid()); |
|
194 | 194 | return $worker; |
195 | 195 | } else { |
196 | 196 | // @codeCoverageIgnoreStart |
197 | 197 | // covered by SnidelTest via worker process |
198 | 198 | // worker |
199 | - $this->log->info('has forked. pid: ' . getmypid()); |
|
199 | + $this->log->info('has forked. pid: '.getmypid()); |
|
200 | 200 | |
201 | 201 | foreach ($this->signals as $sig) { |
202 | - $this->pcntl->signal($sig, function ($sig) { |
|
202 | + $this->pcntl->signal($sig, function($sig) { |
|
203 | 203 | $this->receivedSignal = $sig; |
204 | 204 | exit; |
205 | 205 | }, false); |
206 | 206 | } |
207 | 207 | |
208 | - register_shutdown_function(function () use ($worker) { |
|
208 | + register_shutdown_function(function() use ($worker) { |
|
209 | 209 | if ($this->receivedSignal === null && $worker->isInProgress()) { |
210 | 210 | $worker->error(); |
211 | 211 | } |
@@ -241,14 +241,14 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function sendSignalToMaster($sig = SIGTERM) |
243 | 243 | { |
244 | - $this->log->info('----> sending signal to master. signal: ' . $sig); |
|
244 | + $this->log->info('----> sending signal to master. signal: '.$sig); |
|
245 | 245 | posix_kill($this->master->getPid(), $sig); |
246 | 246 | $this->log->info('<---- sent signal.'); |
247 | 247 | |
248 | 248 | $this->log->info('----> waiting for master shutdown.'); |
249 | 249 | $status = null; |
250 | 250 | $this->pcntl->waitpid($this->master->getPid(), $status); |
251 | - $this->log->info('<---- master shutdown. status: ' . $status); |
|
251 | + $this->log->info('<---- master shutdown. status: '.$status); |
|
252 | 252 | $this->master = null; |
253 | 253 | } |
254 | 254 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(ticks = 1); |
|
2 | +declare(ticks=1); |
|
3 | 3 | |
4 | 4 | namespace Ackintosh; |
5 | 5 | |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | foreach ($this->signals as $sig) { |
43 | 43 | $this->pcntl->signal( |
44 | 44 | $sig, |
45 | - function ($sig) { |
|
46 | - $this->log->info('received signal. signo: ' . $sig); |
|
45 | + function($sig) { |
|
46 | + $this->log->info('received signal. signo: '.$sig); |
|
47 | 47 | $this->log->info('--> sending a signal " to children.'); |
48 | 48 | $this->container->sendSignalToMaster($sig); |
49 | 49 | $this->log->info('<-- signal handling has been completed successfully.'); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
56 | - $this->log->info('parent pid: ' . $this->config->get('ownerPid')); |
|
56 | + $this->log->info('parent pid: '.$this->config->get('ownerPid')); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | throw $e; |
78 | 78 | } |
79 | 79 | |
80 | - $this->log->info('queued task #' . $this->container->queuedCount()); |
|
80 | + $this->log->info('queued task #'.$this->container->queuedCount()); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function results() |
99 | 99 | { |
100 | - foreach($this->container->results() as $r) { |
|
100 | + foreach ($this->container->results() as $r) { |
|
101 | 101 | yield $r; |
102 | 102 | } |
103 | 103 | } |