start('console:build_application', 'Build Application instance and load commands'); $application = Server::get(Application::class); /* base.php will have removed eventual debug options from argv in $_SERVER */ $argv = $_SERVER['argv']; $input = new ArgvInput($argv); $output = new ConsoleOutput(); $application->loadCommands($input, $output); $eventLogger->end('console:build_application'); $eventLogger->start('console:run', 'Run the command'); $application->setAutoExit(false); $exitCode = $application->run($input); $eventLogger->end('console:run'); $profiler = Server::get(IProfiler::class); if ($profiler->isEnabled()) { $eventLogger->end('runtime'); $profile = $profiler->collect(Server::get(IRequest::class), new Response()); $profile->setMethod('occ'); $profile->setUrl(implode(' ', $argv)); $profiler->saveProfile($profile); $urlGenerator = Server::get(IURLGenerator::class); $url = $urlGenerator->linkToRouteAbsolute('profiler.main.profiler', [ 'profiler' => 'db', 'token' => $profile->getToken(), ]); $output->getErrorOutput()->writeln('Profiler output available at ' . $url); } if ($exitCode > 255) { $exitCode = 255; } exit($exitCode); } catch (Exception $ex) { exceptionHandler($ex); } catch (Error $ex) { exceptionHandler($ex); }