This commit is contained in:
2021-01-19 19:33:48 +08:00
parent fa74f62e9c
commit f56fe0c1b4
3 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ class DatabasesProviders extends Providers
$event->on(Event::SERVER_TASK_START, [$this, 'createPool']); $event->on(Event::SERVER_TASK_START, [$this, 'createPool']);
$event = Snowflake::app()->getEvent(); $event = Snowflake::app()->getEvent();
$event->on(Event::SERVER_MANAGER_START, function () { $event->on(Event::SERVER_BEFORE_START, function () {
$attributes = Snowflake::app()->getAttributes(); $attributes = Snowflake::app()->getAttributes();
$attributes->readControllers(MODEL_PATH, 'App\Models', 'models'); $attributes->readControllers(MODEL_PATH, 'App\Models', 'models');
}); });
+2
View File
@@ -138,6 +138,8 @@ class Server extends Application
$configs = Config::get('servers', true); $configs = Config::get('servers', true);
Snowflake::clearWorkerId(); Snowflake::clearWorkerId();
$baseServer = $this->initCore($configs); $baseServer = $this->initCore($configs);
fire(Event::SERVER_BEFORE_START);
if (!$baseServer) { if (!$baseServer) {
return 'ok'; return 'ok';
} }
+1
View File
@@ -43,6 +43,7 @@ class Event extends BaseObject
const SERVER_MANAGER_STOP = 'SERVER:EVENT:MANAGER:START'; const SERVER_MANAGER_STOP = 'SERVER:EVENT:MANAGER:START';
const SERVER_WORKER_STOP = 'SERVER:EVENT:WORKER:STOP'; const SERVER_WORKER_STOP = 'SERVER:EVENT:WORKER:STOP';
const SERVER_WORKER_START = 'SERVER:EVENT:WORKER:START'; const SERVER_WORKER_START = 'SERVER:EVENT:WORKER:START';
const SERVER_BEFORE_START = 'SERVER:EVENT:BEFORE:START';
const SERVER_TASK_START = 'SERVER:EVENT:TASK:START'; const SERVER_TASK_START = 'SERVER:EVENT:TASK:START';
const SERVER_WORKER_EXIT = 'SERVER:EVENT:WORKER:EXIT'; const SERVER_WORKER_EXIT = 'SERVER:EVENT:WORKER:EXIT';
const SERVER_WORKER_ERROR = 'SERVER:EVENT:WORKER:ERROR'; const SERVER_WORKER_ERROR = 'SERVER:EVENT:WORKER:ERROR';