Skip to content

Commit 6a625a8

Browse files
[2.x] Adds --admin-port (#790)
* Adds `--admin-port` * Update StartCommand.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent de6e59b commit 6a625a8

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Commands/StartCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class StartCommand extends Command implements SignalableCommandInterface
1717
{--server= : The server that should be used to serve the application}
1818
{--host= : The IP address the server should bind to}
1919
{--port= : The port the server should be available on [default: "8000"]}
20+
{--admin-port= : The port the admin server should be available on [FrankenPHP only]}
2021
{--rpc-host= : The RPC IP address the server should bind to}
2122
{--rpc-port= : The RPC port the server should be available on}
2223
{--workers=auto : The number of workers that should be available to handle requests}
@@ -102,6 +103,7 @@ protected function startFrankenPhpServer()
102103
return $this->call('octane:frankenphp', [
103104
'--host' => $this->getHost(),
104105
'--port' => $this->getPort(),
106+
'--admin-port' => $this->option('admin-port'),
105107
'--workers' => $this->option('workers'),
106108
'--max-requests' => $this->option('max-requests'),
107109
'--caddyfile' => $this->option('caddyfile'),

src/Commands/StartFrankenPhpCommand.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class StartFrankenPhpCommand extends Command implements SignalableCommandInterfa
2525
public $signature = 'octane:frankenphp
2626
{--host=127.0.0.1 : The IP address the server should bind to}
2727
{--port= : The port the server should be available on}
28+
{--admin-port= : The port the admin server should be available on}
2829
{--workers=auto : The number of workers that should be available to handle requests}
2930
{--max-requests=500 : The number of requests to process before reloading the server}
3031
{--caddyfile= : The path to the FrankenPHP Caddyfile file}
@@ -216,9 +217,19 @@ protected function writeServerStateFile(
216217
*/
217218
protected function adminPort()
218219
{
220+
if ($this->option('admin-port')) {
221+
return (int) $this->option('admin-port');
222+
}
223+
219224
$defaultPort = 2019;
220225

221-
return $defaultPort + ($this->getPort() - 8000);
226+
return tap($defaultPort + ($this->getPort() - 8000), function ($adminPort) {
227+
if ($adminPort < 0) {
228+
throw new InvalidArgumentException(
229+
'Unable to determine admin port. Please specify the [--admin-port] option.',
230+
);
231+
}
232+
});
222233
}
223234

224235
/**

0 commit comments

Comments
 (0)