Skip to content

Commit

Permalink
Fixed --env option, optimize dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
hhxsv5 committed Dec 30, 2020
1 parent f75d9a3 commit e483012
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Components/Apollo/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public static function getDefinition()
public static function callback(Server $swoole, SwooleProcess $process)
{
$filename = base_path('.env');
if (isset($_ENV['LARAVEL_ENV'])) {
$filename .= '.' . $_ENV['LARAVEL_ENV'];
if (isset($_ENV['APP_ENV'])) {
$filename .= '.' . $_ENV['APP_ENV'];
}

self::$apollo = Client::createFromEnv();
Expand Down
8 changes: 4 additions & 4 deletions src/Console/Portal.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function start()
// Generate conf file storage/laravels.conf
$options = $this->input->getOptions();
if (isset($options['env']) && $options['env'] !== '') {
$_SERVER['LARAVEL_ENV'] = $_ENV['LARAVEL_ENV'] = $options['env'];
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $options['env'];
}
if (isset($options['x-version']) && $options['x-version'] !== '') {
$_SERVER['X_VERSION'] = $_ENV['X_VERSION'] = $options['x-version'];
Expand Down Expand Up @@ -293,9 +293,9 @@ public function loadApollo(array $options)
public function makeArtisanCmd($subCmd)
{
$phpCmd = sprintf('%s -c "%s"', PHP_BINARY, php_ini_loaded_file());
$env = $this->input->getOption('env');
$envs = $env ? "APP_ENV={$env}" : '';
return trim(sprintf('%s %s %s/artisan %s', $envs, $phpCmd, $this->basePath, $subCmd));
$env = isset($_ENV['APP_ENV']) ? trim($_ENV['APP_ENV']) : '';
$appEnv = $env === '' ? '' : "APP_ENV={$env}";
return trim(sprintf('%s %s %s/artisan %s', $appEnv, $phpCmd, $this->basePath, $subCmd));
}

public function runArtisanCommand($cmd)
Expand Down
10 changes: 6 additions & 4 deletions src/Illuminate/LaravelSCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ protected function showComponents()
{
$this->comment('>>> Components');
$laravelSVersion = '-';
$cfg = file_exists(base_path('composer.lock')) ? json_decode(file_get_contents(base_path('composer.lock')), true) : [];
$lockFile = base_path('composer.lock');
$cfg = file_exists($lockFile) ? json_decode(file_get_contents($lockFile), true) : [];
if (isset($cfg['packages'])) {
$packages = array_merge($cfg['packages'], Arr::get($cfg, 'packages-dev', []));
foreach ($packages as $package) {
Expand All @@ -98,7 +99,7 @@ protected function showComponents()
$this->table(['Component', 'Version'], [
[
'PHP',
phpversion(),
PHP_VERSION,
],
[
'Swoole',
Expand All @@ -120,6 +121,7 @@ protected function showProtocols()
$this->comment('>>> Protocols');

$config = unserialize((string)file_get_contents($this->getConfPath()));
$ssl = isset($config['server']['swoole']['ssl_key_file'], $config['server']['swoole']['ssl_cert_file']);
$socketType = isset($config['server']['socket_type']) ? $config['server']['socket_type'] : SWOOLE_SOCK_TCP;
if (in_array($socketType, [SWOOLE_SOCK_UNIX_DGRAM, SWOOLE_SOCK_UNIX_STREAM])) {
$listenAt = $config['server']['listen_ip'];
Expand All @@ -132,15 +134,15 @@ protected function showProtocols()
'Main HTTP',
'<info>On</info>',
$this->getApplication()->getName(),
$listenAt,
sprintf('%s://%s', $ssl ? 'https' : 'http', $listenAt),
],
];
if (!empty($config['server']['websocket']['enable'])) {
$tableRows [] = [
'Main WebSocket',
'<info>On</info>',
$config['server']['websocket']['handler'],
$listenAt,
sprintf('%s://%s', $ssl ? 'wss' : 'ws', $listenAt),
];
}

Expand Down

0 comments on commit e483012

Please sign in to comment.