Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Make IP to bind the server to configurable via env #607

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Commands/Concerns/InteractsWithServers.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ protected function getServerOutput($server)
], fn () => $server->clearOutput()->clearErrorOutput());
}

/**
* Get the Octane HTTP server host IP to bind on.
*
* @return string
*/
protected function getHost()
{
return $this->option('host') ?? config('octane.host') ?? $_ENV['OCTANE_HOST'] ?? '127.0.0.1';
}

/**
* Get the Octane HTTP server port.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function handle()
protected function startSwooleServer()
{
return $this->call('octane:swoole', [
'--host' => $this->option('host'),
'--host' => $this->getHost(),
'--port' => $this->getPort(),
'--workers' => $this->option('workers'),
'--task-workers' => $this->option('task-workers'),
Expand All @@ -74,7 +74,7 @@ protected function startSwooleServer()
protected function startRoadRunnerServer()
{
return $this->call('octane:roadrunner', [
'--host' => $this->option('host'),
'--host' => $this->getHost(),
'--port' => $this->getPort(),
'--rpc-port' => $this->option('rpc-port'),
'--workers' => $this->option('workers'),
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/StartRoadRunnerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function writeServerStateFile(
) {
$serverStateFile->writeState([
'appName' => config('app.name', 'Laravel'),
'host' => $this->option('host'),
'host' => $this->getHost(),
'port' => $this->getPort(),
'rpcPort' => $this->rpcPort(),
'workers' => $this->workerCount(),
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/StartSwooleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function writeServerStateFile(
) {
$serverStateFile->writeState([
'appName' => config('app.name', 'Laravel'),
'host' => $this->option('host'),
'host' => $this->getHost(),
'port' => $this->getPort(),
'workers' => $this->workerCount($extension),
'taskWorkers' => $this->taskWorkerCount($extension),
Expand Down