@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | 'class' => self::class, |
| 21 | 21 | 'redirect' => false, |
| 22 | 22 | 'pipe' => 0, |
| 23 | - 'enable' => (bool)getenv('ENABLE_APOLLO'), |
|
| 23 | + 'enable' => (bool) getenv('ENABLE_APOLLO'), |
|
| 24 | 24 | ], |
| 25 | 25 | ]; |
| 26 | 26 | } |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | $filename = base_path('.env'); |
| 31 | 31 | if (isset($_ENV['LARAVEL_ENV'])) { |
| 32 | - $filename .= '.' . $_ENV['LARAVEL_ENV']; |
|
| 32 | + $filename .= '.'.$_ENV['LARAVEL_ENV']; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | self::$apollo = Client::createFromEnv(); |
| 36 | - self::$apollo->startWatchNotification(function (array $notifications) use ($process, $filename) { |
|
| 36 | + self::$apollo->startWatchNotification(function(array $notifications) use ($process, $filename) { |
|
| 37 | 37 | $configs = self::$apollo->pullAllAndSave($filename); |
| 38 | 38 | app('log')->info('[ApolloProcess] Pull all configurations', $configs); |
| 39 | 39 | $process->exec(PHP_BINARY, [base_path('bin/laravels'), 'reload']); |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | if ($value === false) { |
| 132 | 132 | continue; |
| 133 | 133 | } |
| 134 | - $passOptionStr .= sprintf('--%s%s ', $key, is_bool($value) ? '' : ('=' . $value)); |
|
| 134 | + $passOptionStr .= sprintf('--%s%s ', $key, is_bool($value) ? '' : ('='.$value)); |
|
| 135 | 135 | } |
| 136 | - $statusCode = $this->runArtisanCommand(trim('laravels config ' . $passOptionStr)); |
|
| 136 | + $statusCode = $this->runArtisanCommand(trim('laravels config '.$passOptionStr)); |
|
| 137 | 137 | if ($statusCode !== 0) { |
| 138 | 138 | return $statusCode; |
| 139 | 139 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $config = $this->getConfig(); |
| 143 | 143 | |
| 144 | 144 | if (!$config['server']['ignore_check_pid'] && file_exists($config['server']['swoole']['pid_file'])) { |
| 145 | - $pid = (int)file_get_contents($config['server']['swoole']['pid_file']); |
|
| 145 | + $pid = (int) file_get_contents($config['server']['swoole']['pid_file']); |
|
| 146 | 146 | if ($pid > 0 && self::kill($pid, 0)) { |
| 147 | 147 | $this->warning(sprintf('Swoole[PID=%d] is already running.', $pid)); |
| 148 | 148 | return 1; |
@@ -188,8 +188,8 @@ discard block |
||
| 188 | 188 | $basePath = dirname($pidFile); |
| 189 | 189 | $deleteFiles = [ |
| 190 | 190 | $pidFile, |
| 191 | - $basePath . '/laravels-custom-processes.pid', |
|
| 192 | - $basePath . '/laravels-timer-process.pid', |
|
| 191 | + $basePath.'/laravels-custom-processes.pid', |
|
| 192 | + $basePath.'/laravels-timer-process.pid', |
|
| 193 | 193 | ]; |
| 194 | 194 | foreach ($deleteFiles as $deleteFile) { |
| 195 | 195 | if (file_exists($deleteFile)) { |
@@ -239,9 +239,9 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | // Reload custom processes |
| 242 | - $pidFile = dirname($pidFile) . '/laravels-custom-processes.pid'; |
|
| 242 | + $pidFile = dirname($pidFile).'/laravels-custom-processes.pid'; |
|
| 243 | 243 | if (file_exists($pidFile)) { |
| 244 | - $pids = (array)explode("\n", trim(file_get_contents($pidFile))); |
|
| 244 | + $pids = (array) explode("\n", trim(file_get_contents($pidFile))); |
|
| 245 | 245 | unlink($pidFile); |
| 246 | 246 | foreach ($pids as $pid) { |
| 247 | 247 | if (!$pid || !self::kill($pid, 0)) { |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | // Reload timer process |
| 261 | 261 | if (!empty($config['server']['timer']['enable']) && !empty($config['server']['timer']['jobs'])) { |
| 262 | - $pidFile = dirname($pidFile) . '/laravels-timer-process.pid'; |
|
| 262 | + $pidFile = dirname($pidFile).'/laravels-timer-process.pid'; |
|
| 263 | 263 | $pid = file_get_contents($pidFile); |
| 264 | 264 | if (!$pid || !self::kill($pid, 0)) { |
| 265 | 265 | $this->error("Timer process[PID={$pid}] does not exist, or permission denied."); |
@@ -283,9 +283,9 @@ discard block |
||
| 283 | 283 | public function loadApollo(array $options) |
| 284 | 284 | { |
| 285 | 285 | Client::putCommandOptionsToEnv($options); |
| 286 | - $envFile = $this->basePath . '/.env'; |
|
| 286 | + $envFile = $this->basePath.'/.env'; |
|
| 287 | 287 | if (isset($options['env'])) { |
| 288 | - $envFile .= '.' . $options['env']; |
|
| 288 | + $envFile .= '.'.$options['env']; |
|
| 289 | 289 | } |
| 290 | 290 | Client::createFromCommandOptions($options)->pullAllAndSave($envFile); |
| 291 | 291 | } |
@@ -306,8 +306,8 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | public function getConfig() |
| 308 | 308 | { |
| 309 | - $json = file_get_contents($this->basePath . '/storage/laravels.json'); |
|
| 310 | - return (array)json_decode($json, true); |
|
| 309 | + $json = file_get_contents($this->basePath.'/storage/laravels.json'); |
|
| 310 | + return (array) json_decode($json, true); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | public static function runCommand($cmd, $input = null) |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | public static function kill($pid, $sig) |
| 329 | 329 | { |
| 330 | 330 | try { |
| 331 | - return Process::kill((int)$pid, $sig); |
|
| 331 | + return Process::kill((int) $pid, $sig); |
|
| 332 | 332 | } catch (\Exception $e) { |
| 333 | 333 | return false; |
| 334 | 334 | } |