Skip to content

Commit

Permalink
Addresses laravel#332: pass config-file path for roadrunner
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Jun 28, 2021
1 parent 911baa6 commit 4d9b04b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Commands/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class StartCommand extends Command implements SignalableCommandInterface
*/
public $signature = 'octane:start
{--server= : The server that should be used to serve the application}
{--config-path= : The full config path for roadrunner .rr.yaml file. Default .rr.yaml in app dir}
{--host=127.0.0.1 : The IP address the server should bind to}
{--port=8000 : The port the server should be available on}
{--rpc-port= : The RPC port the server should be available on}
Expand Down Expand Up @@ -73,6 +74,7 @@ protected function startRoadRunnerServer()
return $this->call('octane:roadrunner', [
'--host' => $this->option('host'),
'--port' => $this->option('port'),
'--config-path' => $this->option('config-path'),
'--rpc-port' => $this->option('rpc-port'),
'--workers' => $this->option('workers'),
'--max-requests' => $this->option('max-requests'),
Expand Down
19 changes: 16 additions & 3 deletions src/Commands/StartRoadRunnerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class StartRoadRunnerCommand extends Command implements SignalableCommandInterfa
*/
public $signature = 'octane:roadrunner
{--host=127.0.0.1 : The IP address the server should bind to}
{--config-path= : The config path for roadrunner .rr.yaml file}
{--port=8000 : The port the server should be available on}
{--rpc-port= : The RPC port the server should be available on}
{--workers=auto : The number of workers that should be available to handle requests}
Expand Down Expand Up @@ -69,13 +70,11 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve

$this->writeServerStateFile($serverStateFile);

touch(base_path('.rr.yaml'));

$this->forgetEnvironmentVariables();

$server = tap(new Process(array_filter([
$roadRunnerBinary,
'-c', base_path('.rr.yaml'),
'-c', $this->configPath(),
'-o', 'http.address='.$this->option('host').':'.$this->option('port'),
'-o', 'server.command='.(new PhpExecutableFinder)->find().' ./vendor/bin/roadrunner-worker',
'-o', 'http.pool.num_workers='.$this->workerCount(),
Expand Down Expand Up @@ -120,6 +119,20 @@ protected function writeServerStateFile(
]);
}

/**
* Provide road runner config file path.
*
* @return string
*/
protected function configPath()
{
if (!$this->option('config-path')) {
touch(base_path('.rr.yaml'));
return base_path('.rr.yaml');
}
return $this->option('config-path');
}

/**
* Get the number of workers that should be started.
*
Expand Down

0 comments on commit 4d9b04b

Please sign in to comment.