Completed
Pull Request — master (#44)
by Akihito
01:07 queued 13s
created
src/Snidel/Fork/Coordinator.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.