@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | 'class' => self::class, |
22 | 22 | 'redirect' => false, |
23 | 23 | 'pipe' => 0, |
24 | - 'enable' => (bool)getenv('ENABLE_APOLLO'), |
|
24 | + 'enable' => (bool) getenv('ENABLE_APOLLO'), |
|
25 | 25 | ], |
26 | 26 | ]; |
27 | 27 | } |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | { |
31 | 31 | $filename = base_path('.env'); |
32 | 32 | if (isset($_ENV['_ENV'])) { |
33 | - $filename .= '.' . $_ENV['_ENV']; |
|
33 | + $filename .= '.'.$_ENV['_ENV']; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | self::$apollo = Client::createFromEnv(); |
37 | - self::$apollo->startWatchNotification(function (array $notifications) use ($process, $filename) { |
|
37 | + self::$apollo->startWatchNotification(function(array $notifications) use ($process, $filename) { |
|
38 | 38 | $configs = self::$apollo->pullAllAndSave($filename); |
39 | 39 | app('log')->info('[ApolloProcess] Pull all configurations', $configs); |
40 | 40 | Portal::runLaravelSCommand(base_path(), 'reload'); |
@@ -11,7 +11,7 @@ discard block |
||
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 | } |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | continue; |
27 | 27 | } |
28 | 28 | $processClass = $item['class']; |
29 | - $restartInterval = isset($item['restart_interval']) ? (int)$item['restart_interval'] : 5; |
|
30 | - $callback = function (Process $worker) use ($pidfile, $swoole, $processPrefix, $processClass, $restartInterval, $name, $laravelConfig) { |
|
31 | - file_put_contents($pidfile, $worker->pid . "\n", FILE_APPEND | LOCK_EX); |
|
29 | + $restartInterval = isset($item['restart_interval']) ? (int) $item['restart_interval'] : 5; |
|
30 | + $callback = function(Process $worker) use ($pidfile, $swoole, $processPrefix, $processClass, $restartInterval, $name, $laravelConfig) { |
|
31 | + file_put_contents($pidfile, $worker->pid."\n", FILE_APPEND | LOCK_EX); |
|
32 | 32 | $this->initLaravel($laravelConfig, $swoole); |
33 | 33 | if (!isset(class_implements($processClass)[CustomProcessInterface::class])) { |
34 | 34 | throw new \InvalidArgumentException( |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | /**@var CustomProcessInterface $processClass */ |
43 | 43 | $this->setProcessTitle(sprintf('%s laravels: %s process', $processPrefix, $name)); |
44 | 44 | |
45 | - Process::signal(SIGUSR1, function ($signo) use ($name, $processClass, $worker, $pidfile, $swoole) { |
|
45 | + Process::signal(SIGUSR1, function($signo) use ($name, $processClass, $worker, $pidfile, $swoole) { |
|
46 | 46 | $this->info(sprintf('Reloading %s process[PID=%d].', $name, $worker->pid)); |
47 | 47 | $processClass::onReload($swoole, $worker); |
48 | 48 | }); |
49 | 49 | |
50 | 50 | if (method_exists($processClass, 'onStop')) { |
51 | - Process::signal(SIGTERM, function ($signo) use ($name, $processClass, $worker, $pidfile, $swoole) { |
|
51 | + Process::signal(SIGTERM, function($signo) use ($name, $processClass, $worker, $pidfile, $swoole) { |
|
52 | 52 | $this->info(sprintf('Stopping %s process[PID=%d].', $name, $worker->pid)); |
53 | 53 | $processClass::onStop($swoole, $worker); |
54 | 54 | }); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | for ($i = 0; $i < $item['num']; $i++) { |
73 | 73 | $process = $this->makeProcess($callback, $item); |
74 | 74 | $swoole->addProcess($process); |
75 | - $processList[$name . $i] = $process; |
|
75 | + $processList[$name.$i] = $process; |
|
76 | 76 | } |
77 | 77 | } else { // For single process |
78 | 78 | $process = $this->makeProcess($callback, $item); |