Skip to content

Commit

Permalink
Added --rpc-host option (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-inamdar authored Nov 19, 2022
1 parent 7ed5039 commit 3e89616
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Commands/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class StartCommand extends Command implements SignalableCommandInterface
{--server= : The server that should be used to serve the application}
{--host=127.0.0.1 : The IP address the server should bind to}
{--port= : The port the server should be available on [default: "8000"]}
{--rpc-host= : The RPC IP address the server should bind to}
{--rpc-port= : The RPC port the server should be available on}
{--workers=auto : The number of workers that should be available to handle requests}
{--task-workers=auto : The number of task workers that should be available to handle tasks}
Expand Down Expand Up @@ -76,6 +77,7 @@ protected function startRoadRunnerServer()
return $this->call('octane:roadrunner', [
'--host' => $this->getHost(),
'--port' => $this->getPort(),
'--rpc-host' => $this->option('rpc-host'),
'--rpc-port' => $this->option('rpc-port'),
'--workers' => $this->option('workers'),
'--max-requests' => $this->option('max-requests'),
Expand Down
13 changes: 12 additions & 1 deletion src/Commands/StartRoadRunnerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class StartRoadRunnerCommand extends Command implements SignalableCommandInterfa
public $signature = 'octane:roadrunner
{--host=127.0.0.1 : The IP address the server should bind to}
{--port= : The port the server should be available on}
{--rpc-host= : The RPC IP address the server should bind to}
{--rpc-port= : The RPC port the server should be available on}
{--workers=auto : The number of workers that should be available to handle requests}
{--max-requests=500 : The number of requests to process before reloading the server}
Expand Down Expand Up @@ -83,7 +84,7 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve
'-o', 'server.command='.(new PhpExecutableFinder)->find().' '.base_path(config('octane.roadrunner.command', 'vendor/bin/roadrunner-worker')),
'-o', 'http.pool.num_workers='.$this->workerCount(),
'-o', 'http.pool.max_jobs='.$this->option('max-requests'),
'-o', 'rpc.listen=tcp://'.$this->option('host').':'.$this->rpcPort(),
'-o', 'rpc.listen=tcp://'.$this->rpcHost().':'.$this->rpcPort(),
'-o', 'http.pool.supervisor.exec_ttl='.$this->maxExecutionTime(),
'-o', 'http.static.dir='.base_path('public'),
'-o', 'http.middleware='.config('octane.roadrunner.http_middleware', 'static'),
Expand Down Expand Up @@ -167,6 +168,16 @@ protected function maxExecutionTime()
return config('octane.max_execution_time', '30').'s';
}

/**
* Get the RPC IP address the server should be available on.
*
* @return int
*/
protected function rpcHost()
{
return $this->option('rpc-host') ?: $this->getHost();
}

/**
* Get the RPC port the server should be available on.
*
Expand Down

0 comments on commit 3e89616

Please sign in to comment.