1+ #!/usr/bin/env php
2+ <?php
3+
4+ use Bitrix \Main \DB \ConnectionException ;
5+ use Bitrix \Main \Loader ;
6+ use Proklung \Redis \CLI \CommandsSetup ;
7+ use Proklung \Redis \CLI \ConsoleCommandConfigurator ;
8+ use Proklung \Redis \DI \Services ;
9+ use Symfony \Component \Console \Application ;
10+
11+ @set_time_limit (0 );
12+
13+ $ _SERVER ['DOCUMENT_ROOT ' ] = __DIR__ . DIRECTORY_SEPARATOR . '.. ' ;
14+ $ documentRoot = $ GLOBALS ['DOCUMENT_ROOT ' ] = $ _SERVER ['DOCUMENT_ROOT ' ];
15+
16+ $ autoloadPath = $ _SERVER ['DOCUMENT_ROOT ' ] . '/vendor/autoload.php ' ;
17+
18+ define ('BITRIX_CLI ' , true );
19+ define ('NO_KEEP_STATISTIC ' , true );
20+ define ('NOT_CHECK_PERMISSIONS ' , true );
21+ define ('LANGUAGE_ID ' , 'pa ' );
22+ define ('LOG_FILENAME ' , 'php://stderr ' );
23+ define ('BX_NO_ACCELERATOR_RESET ' , true );
24+ define ('STOP_STATISTICS ' , true );
25+ define ('NO_AGENT_STATISTIC ' , 'Y ' );
26+ define ('NO_AGENT_CHECK ' , true );
27+ defined ('PUBLIC_AJAX_MODE ' ) || define ('PUBLIC_AJAX_MODE ' , true );
28+
29+ /** @noinspection PhpIncludeInspection */
30+ require_once $ autoloadPath ;
31+
32+ try {
33+
34+ global
35+ $ DB , $ DBType , $ DBHost , $ DBLogin , $ DBPassword ,
36+ $ DBName , $ DBDebug , $ DBDebugToFile , $ APPLICATION , $ USER , $ DBSQLServerType ;
37+
38+ require_once $ documentRoot . '/bitrix/modules/main/include/prolog_before.php ' ;
39+
40+ $ bitrixStatus = 0 ;
41+
42+ if (defined ('B_PROLOG_INCLUDED ' ) && B_PROLOG_INCLUDED === true ) {
43+ $ bitrixStatus = 200 ;
44+ }
45+
46+ // Альтернативный способ вывода ошибок типа "DB query error.":
47+ $ GLOBALS ['DB ' ]->debug = true ;
48+
49+ $ app = \Bitrix \Main \Application::getInstance ();
50+ $ con = $ app ->getConnection ();
51+ $ DB ->db_Conn = $ con ->getResource ();
52+
53+ if (in_array (\PHP_SAPI , ['cli ' , 'phpdbg ' , 'embed ' ], true ) === false ) {
54+ echo 'Warning: The console should be invoked via the CLI version of PHP, not the '
55+ . \PHP_SAPI . ' SAPI ' . \PHP_EOL ;
56+ }
57+ } catch (ConnectionException $ e ) {
58+ $ bitrixStatus = 404 ;
59+ }
60+
61+ if ($ bitrixStatus !== 200 ) {
62+ exit ('Bitrix not loaded. ' );
63+ }
64+
65+ Loader::includeModule ('proklung.redis ' );
66+
67+ $ services = new Services ();
68+ $ services ->load ();
69+ $ container = $ services ->getContainer ();
70+
71+ $ commands = CommandsSetup::load ($ container );
72+
73+ $ application = new ConsoleCommandConfigurator (
74+ new Application (),
75+ ...$ commands
76+ );
77+
78+ $ application ->init ();
79+ $ application ->run ();
0 commit comments