Enable Swoole hooks after the blocking start-up work

This commit is contained in:
Jonathan Sykes
2026-10-14 02:46:27 +08:00
parent 6afb5aed6e
commit d5a175cf45

View File

@@ -11,7 +11,6 @@ require __DIR__ . '/asset-manifest.php';
require __DIR__ . '/database.php';
require __DIR__ . '/media-cache.php';
Swoole\Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL);
date_default_timezone_set('UTC');
$root = getenv('PUBLIC_DIR') ?: '/app/public';
@@ -36,6 +35,8 @@ $media = null;
// Create the schema before Swoole forks; PDO handles are never inherited by workers.
$schemaStore = new Store($dbPath);
$schemaStore->close();
// Hooks go on only after the blocking start-up work above (proc_open needs a coroutine once hooked).
Swoole\Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL);
$mime = ['html'=>'text/html; charset=utf-8','js'=>'text/javascript; charset=utf-8','mjs'=>'text/javascript; charset=utf-8','css'=>'text/css; charset=utf-8','json'=>'application/json; charset=utf-8','webmanifest'=>'application/manifest+json','svg'=>'image/svg+xml','png'=>'image/png','jpg'=>'image/jpeg','jpeg'=>'image/jpeg','webp'=>'image/webp','woff2'=>'font/woff2','woff'=>'font/woff','ttf'=>'font/ttf','wasm'=>'application/wasm','ico'=>'image/x-icon','txt'=>'text/plain; charset=utf-8','mp4'=>'video/mp4','m4a'=>'audio/mp4'];
$searchMem=[]; $searchInFlight=[]; $streamMem=[]; $streamInFlight=[]; $searchMax=200; $searchTtl=600; $searchStale=15*86400; $searchWrites=0;