Completed
Pull Request — master (#266)
by
unknown
06:19 queued 02:53
created
src/Swoole/Process/CustomProcessTrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
     public function addCustomProcesses(Server $swoole, $processPrefix, array $processes, array $laravelConfig)
13 13
     {
14
-        $pidfile = dirname($swoole->setting['pid_file']) . '/' . $this->customProcessPidFile;
14
+        $pidfile = dirname($swoole->setting['pid_file']).'/'.$this->customProcessPidFile;
15 15
         if (file_exists($pidfile)) {
16 16
             unlink($pidfile);
17 17
         }
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
                 continue;
30 30
             }
31 31
             $processClass = $item['class'];
32
-            $restartInterval = isset($item['restart_interval']) ? (int)$item['restart_interval'] : 5;
33
-            $callback = function (Process $worker) use ($pidfile, $swoole, $processPrefix, $processClass, $restartInterval, $name, $laravelConfig) {
34
-                file_put_contents($pidfile, $worker->pid . "\n", FILE_APPEND | LOCK_EX);
32
+            $restartInterval = isset($item['restart_interval']) ? (int) $item['restart_interval'] : 5;
33
+            $callback = function(Process $worker) use ($pidfile, $swoole, $processPrefix, $processClass, $restartInterval, $name, $laravelConfig) {
34
+                file_put_contents($pidfile, $worker->pid."\n", FILE_APPEND | LOCK_EX);
35 35
                 $this->initLaravel($laravelConfig, $swoole);
36 36
                 if (!isset(class_implements($processClass)[CustomProcessInterface::class])) {
37 37
                     throw new \InvalidArgumentException(
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
                 /**@var CustomProcessInterface $processClass */
46 46
                 $this->setProcessTitle(sprintf('%s laravels: %s process', $processPrefix, $name));
47 47
 
48
-                Process::signal(SIGUSR1, function ($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
48
+                Process::signal(SIGUSR1, function($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
49 49
                     $this->info(sprintf('Reloading %s process[PID=%d].', $name, $worker->pid));
50 50
                     $processClass::onReload($swoole, $worker);
51 51
                 });
52 52
 
53 53
                 if (method_exists($processClass, 'onStop')) {
54
-                    Process::signal(SIGTERM, function ($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
54
+                    Process::signal(SIGTERM, function($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
55 55
                         $this->info(sprintf('Stopping %s process[PID=%d].', $name, $worker->pid));
56 56
                         $processClass::onStop($swoole, $worker);
57 57
                     });
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
                 $coroutineAvailable = class_exists('Swoole\Coroutine');
61 61
                 $coroutineRuntimeAvailable = class_exists('Swoole\Runtime');
62
-                $runProcess = function () use ($name, $processClass, $restartInterval, $swoole, $worker, $coroutineAvailable, $coroutineRuntimeAvailable) {
62
+                $runProcess = function() use ($name, $processClass, $restartInterval, $swoole, $worker, $coroutineAvailable, $coroutineRuntimeAvailable) {
63 63
                     $coroutineRuntimeAvailable && \Swoole\Runtime::enableCoroutine();
64 64
                     $this->callWithCatchException([$processClass, 'callback'], [$swoole, $worker]);
65 65
                     // Avoid frequent process creation
Please login to merge, or discard this patch.