Skip to content

Commit

Permalink
Add --admin-host to frankenphp command
Browse files Browse the repository at this point in the history
Users can now override the admin host bind using command line arguments
  • Loading branch information
alextricity25 committed May 24, 2024
1 parent b5a56f4 commit 6f5e4bb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Commands/StartFrankenPhpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class StartFrankenPhpCommand extends Command implements SignalableCommandInterfa
{--host=127.0.0.1 : The IP address the server should bind to}
{--port= : The port the server should be available on}
{--admin-port= : The port the admin server should be available on}
{--admin-host= : The host the admin server should be availble on}
{--workers=auto : The number of workers that should be available to handle requests}
{--max-requests=500 : The number of requests to process before reloading the server}
{--caddyfile= : The path to the FrankenPHP Caddyfile file}
Expand Down Expand Up @@ -97,6 +98,7 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve
'REQUEST_MAX_EXECUTION_TIME' => $this->maxExecutionTime(),
'CADDY_GLOBAL_OPTIONS' => ($https && $this->option('http-redirect')) ? '' : 'auto_https disable_redirects',
'CADDY_SERVER_ADMIN_PORT' => $this->adminPort(),
'CADDY_SERVER_ADMIN_HOST' => $this->adminHost(),
'CADDY_SERVER_LOG_LEVEL' => $this->option('log-level') ?: (app()->environment('local') ? 'INFO' : 'WARN'),
'CADDY_SERVER_LOGGER' => 'json',
'CADDY_SERVER_SERVER_NAME' => $serverName,
Expand Down Expand Up @@ -210,6 +212,7 @@ protected function writeServerStateFile(
'host' => $this->getHost(),
'port' => $this->getPort(),
'adminPort' => $this->adminPort(),
'adminHost' => $this->adminHost(),
'workers' => $this->workerCount(),
'maxRequests' => $this->option('max-requests'),
'octaneConfig' => config('octane'),
Expand Down Expand Up @@ -237,6 +240,21 @@ protected function adminPort()
}
});
}

/**
* Get the host the admin API should be available on.
*
* @return string
*/
protected function adminHost()
{
if ($this->option('admin-host')) {
return (string) $this->option('admin-host');
}

return 'localhost';

}

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

0 comments on commit 6f5e4bb

Please sign in to comment.