Skip to content

Commit

Permalink
Automatically disable worker mode in local environments if workers ar…
Browse files Browse the repository at this point in the history
…en't specified explicitly
  • Loading branch information
Radiergummi committed Jul 24, 2024
1 parent e5126e7 commit 611b90b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Commands/StartFrankenPhpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve
'APP_ENV' => app()->environment(),
'APP_BASE_PATH' => base_path(),
'APP_PUBLIC_PATH' => public_path(),
'APP_INDEX_FILE' => $this->workerCount() == 0 && app()->environment('local') ? 'index.php' : 'frankenphp-worker.php',
'LARAVEL_OCTANE' => 1,
'MAX_REQUESTS' => $this->option('max-requests'),
'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->option('admin-host'),
'CADDY_SERVER_FRANKENPHP_OPTIONS' => $this->workerCount() == 0 && app()->environment('local') ? '' : 'import worker',
'CADDY_SERVER_LOG_LEVEL' => $this->option('log-level') ?: (app()->environment('local') ? 'INFO' : 'WARN'),
'CADDY_SERVER_LOGGER' => 'json',
'CADDY_SERVER_SERVER_NAME' => $serverName,
Expand Down
9 changes: 7 additions & 2 deletions src/Commands/stubs/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
(worker) {
worker "{$APP_PUBLIC_PATH}/frankenphp-worker.php" {$CADDY_SERVER_WORKER_COUNT}
}

{
{$CADDY_GLOBAL_OPTIONS}

admin {$CADDY_SERVER_ADMIN_HOST}:{$CADDY_SERVER_ADMIN_PORT}

frankenphp {
worker "{$APP_PUBLIC_PATH}/frankenphp-worker.php" {$CADDY_SERVER_WORKER_COUNT}
{$CADDY_SERVER_FRANKENPHP_OPTIONS}
}
}

Expand All @@ -31,7 +35,8 @@
{$CADDY_SERVER_EXTRA_DIRECTIVES}

php_server {
index frankenphp-worker.php
index {$APP_INDEX_FILE}

# Required for the public/storage/ directory...
resolve_root_symlink
}
Expand Down

0 comments on commit 611b90b

Please sign in to comment.