diff --git a/app/pub/index.php.sample b/app/pub/index.php.sample index a683d26..0d9f9f8 100644 --- a/app/pub/index.php.sample +++ b/app/pub/index.php.sample @@ -20,48 +20,33 @@ HTML; exit(1); } +$bootstrap = Bootstrap::create( + BP, + $_SERVER); if (isset($_SERVER['FRANKENPHP_WORKER_ENABLE']) && $_SERVER['FRANKENPHP_WORKER_ENABLE'] == 1) { -#Mode worker - $nbRequests = 0; - for($nbRequests = 0, $running = true; isset($_SERVER['MAX_REQUESTS']) && ($nbRequests < ((int)$_SERVER['MAX_REQUESTS'])) && $running; ++$nbRequests) { - frankenphp_handle_request(function () use($nbRequests): void + $maxRequests = (int)($_SERVER['MAX_REQUESTS'] ?? 0); + for($nbRequests = 0; !$maxRequests || $nbRequests < $maxRequests; ++$nbRequests) { + $keepRunning = \frankenphp_handle_request(function () use($nbRequests, $bootstrap): void { - - - $bootstrap = Bootstrap::create( - BP, - $_SERVER); $app = $bootstrap->createApplication(\Magento\Framework\App\Http::class); $bootstrap->run($app); - - //DEBUG - // echo '
WORKER MODE: ON ITERATION '.$nbRequests.'
'; - }); - //var_dump($running); - gc_collect_cycles(); \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\App\ResourceConnection::class)->closeConnection(); - + if (!$keepRunning) break; } - } else { #DEFAULT MODE - $bootstrap = Bootstrap::create( BP, $_SERVER); $app = $bootstrap->createApplication(\Magento\Framework\App\Http::class); $bootstrap->run($app); -//DEBUG - echo '
$_SERVER[\'SERVER_SOFTWARE\'] : '.$_SERVER['SERVER_SOFTWARE'].'
'; - - }