改进 IP 监听

This commit is contained in:
iVampireSP.com 2023-02-08 20:53:58 +08:00
parent 5762c8a3d6
commit 340b082ee8
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -70,16 +70,27 @@ public function handle(): int
// 关闭 Octane
Artisan::call('octane:stop');
if (! config('settings.node.ip')) {
// 刷新配置缓存
$this->info('正在刷新配置缓存。');
Artisan::call('config:cache');
Artisan::call('route:cache');
$node_ip = config('settings.node.ip');
if (!$node_ip) {
$this->error('请先配置节点 IP。');
return CommandAlias::FAILURE;
}
// 刷新配置缓存
$this->info('正在刷新配置缓存。');
Artisan::call('config:cache');
Artisan::call('route:cache');
// 获取端口
$node_ips = explode(':', $node_ip);
$node_host = $node_ips[0];
if (count($node_ips) === 1) {
$node_port = 8000;
} else {
$node_port = $node_ips[1];
}
// redis 创建一个 hash
$this->info('正在注册节点。');
@ -105,7 +116,7 @@ public function handle(): int
// 子进程
$this->info('正在启动 Web。');
$command = 'php artisan octane:start --host=0.0.0.0 --rpc-port=6001 --port=8000';
$command = "php artisan octane:start --host=$node_host --port=$node_port";
$this->pipeCommand($command);
} else {
$this->report();