@@ -33,25 +33,18 @@ class Autoload
3333{
3434 public static function start (?string $ arg = null , ?Server $ server = null ): void
3535 {
36- if (in_array ($ arg ?? '' , ['start ' , 'restart ' , 'stop ' , 'status ' , 'reload ' , 'connections ' ])) {
37- // Предзагрузка
38- Config::reloadAll (['route ' , 'container ' ]);
39- static ::system ();
40- } else if ($ server instanceof Server) {
41- // При старте сервера
42- Config::reloadAll (['route ' ]);
43- register_shutdown_function (fn ($ s ): int |bool => (time () - $ s <= 1 ) ? sleep (1 ) : true , time ());
44- static ::system ();
45- static ::files ();
46- Bootstrap::start ($ server );
36+ Config::reloadAll (['route ' ]);
37+ static ::system ();
38+
39+ if (($ server instanceof Server)
40+ || !in_array ($ arg ?? '' , ['start ' , 'restart ' , 'stop ' , 'status ' , 'reload ' , 'connections ' ])
41+ ) {
42+ if ($ server instanceof Server) {
43+ register_shutdown_function (fn ($ s ): int |bool => (time () - $ s <= 0.1 ) ? sleep (1 ) : true , time ());
44+ }
4745 Context::init ();
48- } else {
49- // CLI
50- Config::reloadAll (['route ' ]);
51- set_error_handler (fn ($ l , $ m , $ f = '' , $ n = 0 ): bool => (error_reporting () & $ l ) ? throw new ErrorException ($ m , 0 , $ l , $ f , $ n ) : true );
52- static ::system ();
5346 static ::files ();
54- Bootstrap::start ();
47+ Bootstrap::start ($ server );
5548 }
5649 }
5750
@@ -60,6 +53,7 @@ private static function system(): void
6053 ini_set ('display_errors ' , 'on ' );
6154 error_reporting (config ('server.error_reporting ' , E_ALL ));
6255 date_default_timezone_set (config ('server.default_timezone ' , config ('app.default_timezone ' , 'Europe/Moscow ' )));
56+ set_error_handler (fn ($ l , $ m , $ f = '' , $ n = 0 ): bool => (error_reporting () & $ l ) ? throw new ErrorException ($ m , 0 , $ l , $ f , $ n ) : true );
6357 }
6458
6559 public static function files (): void
0 commit comments