33namespace Laravel \Octane \Commands ;
44
55use Illuminate \Support \Str ;
6+ use InvalidArgumentException ;
67use Laravel \Octane \RoadRunner \ServerProcessInspector ;
78use Laravel \Octane \RoadRunner \ServerStateFile ;
89use 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