start('console:build_application', 'Build Application instance and load commands'); $application = \OCP\Server::get(Application::class); $argv = $_SERVER['argv']; if (($key = array_search('--debug', $argv)) !== false) { // Remove --debug option if it was passed unset($argv[$key]); $argv = array_values($argv); } $input = new ArgvInput($argv); $application->loadCommands($input, new ConsoleOutput()); $eventLogger->end('console:build_application'); $eventLogger->start('console:run', 'Run the command'); $application->setAutoExit(false); $exitCode = $application->run($input); $eventLogger->end('console:run'); $profiler = \OCP\Server::get(IProfiler::class); if ($profiler->isEnabled()) { $eventLogger->end('runtime'); $profile = $profiler->collect(\OCP\Server::get(IRequest::class), new Response()); $profile->setMethod('occ'); $profile->setUrl(implode(' ', $argv)); $profiler->saveProfile($profile); } if ($exitCode > 255) { $exitCode = 255; } exit($exitCode); } catch (Exception $ex) { exceptionHandler($ex); } catch (Error $ex) { exceptionHandler($ex); }