Skip to content

Commit

Permalink
Make IP to bind the server to configurable via env (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
xorinzor authored Nov 2, 2022
1 parent 8caf947 commit 24ab7f9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
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

0 comments on commit 24ab7f9

Please sign in to comment.