Skip to content

Commit a4e9602

Browse files
Addresses #332: pass config-file path for roadrunner (#335)
* Addresses #332: pass config-file path for roadrunner * style * check absolute path * foramtting Co-authored-by: Taylor Otwell <[email protected]>
1 parent 7c56189 commit a4e9602

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/Commands/StartCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class StartCommand extends Command implements SignalableCommandInterface
2121
{--workers=auto : The number of workers that should be available to handle requests}
2222
{--task-workers=auto : The number of task workers that should be available to handle tasks}
2323
{--max-requests=500 : The number of requests to process before reloading the server}
24+
{--config= : The path to the RoadRunner .rr.yaml file}
2425
{--watch : Automatically reload the server when the application is modified}';
2526

2627
/**
@@ -76,6 +77,7 @@ protected function startRoadRunnerServer()
7677
'--rpc-port' => $this->option('rpc-port'),
7778
'--workers' => $this->option('workers'),
7879
'--max-requests' => $this->option('max-requests'),
80+
'--config' => $this->option('config'),
7981
'--watch' => $this->option('watch'),
8082
]);
8183
}

src/Commands/StartRoadRunnerCommand.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Laravel\Octane\Commands;
44

55
use Illuminate\Support\Str;
6+
use InvalidArgumentException;
67
use Laravel\Octane\RoadRunner\ServerProcessInspector;
78
use Laravel\Octane\RoadRunner\ServerStateFile;
89
use Symfony\Component\Console\Command\SignalableCommandInterface;
@@ -26,6 +27,7 @@ class StartRoadRunnerCommand extends Command implements SignalableCommandInterfa
2627
{--rpc-port= : The RPC port the server should be available on}
2728
{--workers=auto : The number of workers that should be available to handle requests}
2829
{--max-requests=500 : The number of requests to process before reloading the server}
30+
{--config= : The path to the RoadRunner .rr.yaml file}
2931
{--watch : Automatically reload the server when the application is modified}';
3032

3133
/**
@@ -69,13 +71,11 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve
6971

7072
$this->writeServerStateFile($serverStateFile);
7173

72-
touch(base_path('.rr.yaml'));
73-
7474
$this->forgetEnvironmentVariables();
7575

7676
$server = tap(new Process(array_filter([
7777
$roadRunnerBinary,
78-
'-c', base_path('.rr.yaml'),
78+
'-c', $this->configPath(),
7979
'-o', 'http.address='.$this->option('host').':'.$this->option('port'),
8080
'-o', 'server.command='.(new PhpExecutableFinder)->find().' ./vendor/bin/roadrunner-worker',
8181
'-o', 'http.pool.num_workers='.$this->workerCount(),
@@ -132,6 +132,28 @@ protected function workerCount()
132132
: $this->option('workers');
133133
}
134134

135+
/**
136+
* Get the path to the RoadRunner configuration file.
137+
*
138+
* @return string
139+
*/
140+
protected function configPath()
141+
{
142+
$path = $this->option('config');
143+
144+
if (! $path) {
145+
touch(base_path('.rr.yaml'));
146+
147+
return base_path('.rr.yaml');
148+
}
149+
150+
if ($path && ! realpath($path)) {
151+
throw new InvalidArgumentException('Unable to locate specified configuration file.');
152+
}
153+
154+
return realpath($path);
155+
}
156+
135157
/**
136158
* Get the maximum number of seconds that workers should be allowed to execute a single request.
137159
*

0 commit comments

Comments
 (0)