@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | try { |
106 | 106 | $this->master = $this->pcntl->fork(); |
107 | 107 | } catch (\RuntimeException $e) { |
108 | - $message = 'failed to fork master: ' . $e->getMessage(); |
|
108 | + $message = 'failed to fork master: '.$e->getMessage(); |
|
109 | 109 | $this->log->error($message); |
110 | 110 | throw new \RuntimeException($message); |
111 | 111 | } |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | |
115 | 115 | if (getmypid() === $this->config->get('ownerPid')) { |
116 | 116 | // owner |
117 | - $this->log->info('pid: ' . getmypid()); |
|
118 | - $this->resultQueue = $this->factory->create('result'); |
|
117 | + $this->log->info('pid: '.getmypid()); |
|
118 | + $this->resultQueue = $this->factory->create('result'); |
|
119 | 119 | |
120 | 120 | return $this->master; |
121 | 121 | } else { |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | // covered by SnidelTest via master process |
124 | 124 | // master |
125 | 125 | $workerPool = new WorkerPool(); |
126 | - $this->log->info('pid: ' . $this->master->getPid()); |
|
126 | + $this->log->info('pid: '.$this->master->getPid()); |
|
127 | 127 | |
128 | 128 | foreach ($this->signals as $sig) { |
129 | - $this->pcntl->signal($sig, function ($sig) use ($workerPool) { |
|
129 | + $this->pcntl->signal($sig, function($sig) use ($workerPool) { |
|
130 | 130 | $this->receivedSignal = $sig; |
131 | - $this->log->info('received signal: ' . $sig); |
|
131 | + $this->log->info('received signal: '.$sig); |
|
132 | 132 | |
133 | 133 | if ($workerPool->count() === 0) { |
134 | 134 | $this->log->info('no worker is active.'); |
135 | 135 | } else { |
136 | - $this->log->info('------> sending signal to workers. signal: ' . $sig); |
|
136 | + $this->log->info('------> sending signal to workers. signal: '.$sig); |
|
137 | 137 | $workerPool->terminate($sig); |
138 | 138 | $this->log->info('<------ sent signal'); |
139 | 139 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | }); |
142 | 142 | } |
143 | 143 | |
144 | - $concurrency = (int)$this->config->get('concurrency'); |
|
144 | + $concurrency = (int) $this->config->get('concurrency'); |
|
145 | 145 | for ($i = 0; $i < $concurrency; $i++) { |
146 | 146 | $workerPool->add($this->forkWorker()); |
147 | 147 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | try { |
171 | 171 | $process = $this->pcntl->fork(); |
172 | 172 | } catch (\RuntimeException $e) { |
173 | - $message = 'failed to fork worker: ' . $e->getMessage(); |
|
173 | + $message = 'failed to fork worker: '.$e->getMessage(); |
|
174 | 174 | $this->log->error($message); |
175 | 175 | throw new \RuntimeException($message); |
176 | 176 | } |
@@ -179,22 +179,22 @@ discard block |
||
179 | 179 | |
180 | 180 | if (getmypid() === $this->master->getPid()) { |
181 | 181 | // master |
182 | - $this->log->info('forked worker. pid: ' . $worker->getPid()); |
|
182 | + $this->log->info('forked worker. pid: '.$worker->getPid()); |
|
183 | 183 | return $worker; |
184 | 184 | } else { |
185 | 185 | // @codeCoverageIgnoreStart |
186 | 186 | // covered by SnidelTest via worker process |
187 | 187 | // worker |
188 | - $this->log->info('has forked. pid: ' . getmypid()); |
|
188 | + $this->log->info('has forked. pid: '.getmypid()); |
|
189 | 189 | |
190 | 190 | foreach ($this->signals as $sig) { |
191 | - $this->pcntl->signal($sig, function ($sig) { |
|
191 | + $this->pcntl->signal($sig, function($sig) { |
|
192 | 192 | $this->receivedSignal = $sig; |
193 | 193 | exit; |
194 | 194 | }, false); |
195 | 195 | } |
196 | 196 | |
197 | - register_shutdown_function(function () use ($worker) { |
|
197 | + register_shutdown_function(function() use ($worker) { |
|
198 | 198 | if ($this->receivedSignal === null && $worker->isInProgress()) { |
199 | 199 | $worker->error(); |
200 | 200 | } |
@@ -225,14 +225,14 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function sendSignalToMaster($sig = SIGTERM): void |
227 | 227 | { |
228 | - $this->log->info('----> sending signal to master. signal: ' . $sig); |
|
228 | + $this->log->info('----> sending signal to master. signal: '.$sig); |
|
229 | 229 | posix_kill($this->master->getPid(), $sig); |
230 | 230 | $this->log->info('<---- sent signal.'); |
231 | 231 | |
232 | 232 | $this->log->info('----> waiting for master shutdown.'); |
233 | 233 | $status = null; |
234 | 234 | $this->pcntl->waitpid($this->master->getPid(), $status); |
235 | - $this->log->info('<---- master shutdown. status: ' . $status); |
|
235 | + $this->log->info('<---- master shutdown. status: '.$status); |
|
236 | 236 | $this->master = null; |
237 | 237 | } |
238 | 238 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $this->coordinator = new Coordinator($this->config, $this->log); |
39 | 39 | $this->coordinator->forkMaster(); |
40 | 40 | $this->registerSignalHandler($this->coordinator, $this->log); |
41 | - $this->log->info('parent pid: ' . $this->config->get('ownerPid')); |
|
41 | + $this->log->info('parent pid: '.$this->config->get('ownerPid')); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | $tag) |
60 | 60 | ); |
61 | 61 | } catch (\RuntimeException $e) { |
62 | - $this->log->error('failed to enqueue the task: ' . $e->getMessage()); |
|
62 | + $this->log->error('failed to enqueue the task: '.$e->getMessage()); |
|
63 | 63 | throw $e; |
64 | 64 | } |
65 | 65 | |
66 | - $this->log->info('queued task #' . $this->coordinator->queuedCount()); |
|
66 | + $this->log->info('queued task #'.$this->coordinator->queuedCount()); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function results(): \Generator |
81 | 81 | { |
82 | - foreach($this->coordinator->results() as $r) { |
|
82 | + foreach ($this->coordinator->results() as $r) { |
|
83 | 83 | yield $r; |
84 | 84 | } |
85 | 85 | } |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | foreach ($this->signals as $sig) { |
105 | 105 | $pcntl->signal( |
106 | 106 | $sig, |
107 | - function ($sig) use ($log, $coordinator) { |
|
108 | - $log->info('received signal. signo: ' . $sig); |
|
107 | + function($sig) use ($log, $coordinator) { |
|
108 | + $log->info('received signal. signo: '.$sig); |
|
109 | 109 | $log->info('--> sending a signal " to children.'); |
110 | 110 | $coordinator->sendSignalToMaster($sig); |
111 | 111 | $log->info('<-- signal handling has been completed successfully.'); |