From 4d9b04b9386e11ac13666a4ab1605377bdc75ee3 Mon Sep 17 00:00:00 2001 From: Pulkit Kathuria Date: Mon, 28 Jun 2021 17:15:53 +0900 Subject: [PATCH] Addresses #332: pass config-file path for roadrunner --- src/Commands/StartCommand.php | 2 ++ src/Commands/StartRoadRunnerCommand.php | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Commands/StartCommand.php b/src/Commands/StartCommand.php index 92a64ad11..de0da23f3 100644 --- a/src/Commands/StartCommand.php +++ b/src/Commands/StartCommand.php @@ -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} @@ -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'), diff --git a/src/Commands/StartRoadRunnerCommand.php b/src/Commands/StartRoadRunnerCommand.php index dc1b3f1b9..0e99694be 100644 --- a/src/Commands/StartRoadRunnerCommand.php +++ b/src/Commands/StartRoadRunnerCommand.php @@ -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} @@ -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(), @@ -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. *