#!/usr/bin/env php
<?php

use Bitrix\Main\Loader;
use Bsi\Queue\Queue;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;

set_time_limit(0);

define('NO_KEEP_STATISTIC', true);
define('NOT_CHECK_PERMISSIONS', true);
define('BX_NO_ACCELERATOR_RESET', true);
define('BX_CRONTAB', true);
define('STOP_STATISTICS', true);
define('NO_AGENT_STATISTIC', 'Y');
define('DisableEventsCheck', true);
define('NO_AGENT_CHECK', true);

$_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__DIR__, 4));
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];

require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';

@session_destroy();

Loader::includeModule('bsi.queue');

$container = Queue::getInstance()->getContainer();
$application = new Application();
$commandLoader = $container->get('console.command_loader');
if ($commandLoader instanceof CommandLoaderInterface) {
    $application->setCommandLoader($commandLoader);
}
$application->run();
