Completed
Pull Request — master (#266)
by
unknown
03:29
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,19 +45,19 @@  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
-                Process::signal(SIGTERM, function ($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
53
+                Process::signal(SIGTERM, function($signo) use ($name, $processClass, $worker, $pidfile, $swoole) {
54 54
                     $this->info(sprintf('Stopping %s process[PID=%d].', $name, $worker->pid));
55 55
                     $processClass::onStop($swoole, $worker);
56 56
                 });
57 57
 
58 58
                 $coroutineAvailable = class_exists('Swoole\Coroutine');
59 59
                 $coroutineRuntimeAvailable = class_exists('Swoole\Runtime');
60
-                $runProcess = function () use ($name, $processClass, $restartInterval, $swoole, $worker, $coroutineAvailable, $coroutineRuntimeAvailable) {
60
+                $runProcess = function() use ($name, $processClass, $restartInterval, $swoole, $worker, $coroutineAvailable, $coroutineRuntimeAvailable) {
61 61
                     $coroutineRuntimeAvailable && \Swoole\Runtime::enableCoroutine();
62 62
                     $this->callWithCatchException([$processClass, 'callback'], [$swoole, $worker]);
63 63
                     // Avoid frequent process creation
Please login to merge, or discard this patch.