@@ -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 | } |
@@ -29,9 +29,9 @@ discard block |
||
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 |
||
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 | }); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | for ($i = 0; $i < $item['num']; $i++) { |
77 | 77 | $process = $this->makeProcess($callback, $item); |
78 | 78 | $swoole->addProcess($process); |
79 | - $processList[$name . $i] = $process; |
|
79 | + $processList[$name.$i] = $process; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return $processList; |