This commit is contained in:
2021-03-02 18:51:45 +08:00
parent 9d1df92ad0
commit bd2f7b72a0
5 changed files with 10 additions and 5 deletions
-5
View File
@@ -24,13 +24,8 @@ class OnBeforeReload extends Callback
*/ */
public function onHandler(Server $server) public function onHandler(Server $server)
{ {
Timer::clearAll();
$event = Snowflake::app()->getEvent(); $event = Snowflake::app()->getEvent();
$event->trigger(Event::SERVER_BEFORE_RELOAD, [$server]); $event->trigger(Event::SERVER_BEFORE_RELOAD, [$server]);
$this->clearMysqlClient();
$this->clearRedisClient();
} }
} }
+2
View File
@@ -23,6 +23,8 @@ class OnWorkerExit extends Callback
*/ */
public function onHandler($server, $worker_id) public function onHandler($server, $worker_id)
{ {
putenv('state=exit');
$event = Snowflake::app()->getEvent(); $event = Snowflake::app()->getEvent();
$event->trigger(Event::SERVER_WORKER_EXIT); $event->trigger(Event::SERVER_WORKER_EXIT);
$event->offName(Event::SERVER_WORKER_EXIT); $event->offName(Event::SERVER_WORKER_EXIT);
+1
View File
@@ -38,6 +38,7 @@ class OnWorkerStart extends Callback
public function onHandler(Server $server, int $worker_id): void public function onHandler(Server $server, int $worker_id): void
{ {
putenv('worker=' . $worker_id); putenv('worker=' . $worker_id);
putenv('state=start');
if ($worker_id >= $server->setting['worker_num']) { if ($worker_id >= $server->setting['worker_num']) {
$this->onTask($server, $worker_id); $this->onTask($server, $worker_id);
+4
View File
@@ -51,6 +51,10 @@ abstract class Pool extends Component
*/ */
public function Heartbeat_detection() public function Heartbeat_detection()
{ {
if (env('state') == 'exit') {
$this->flush(0);
return;
}
if ($this->lastTime == 0) { if ($this->lastTime == 0) {
return; return;
} }
+3
View File
@@ -43,6 +43,9 @@ class Application extends BaseApplication
public string $id = 'uniqueId'; public string $id = 'uniqueId';
public string $state = '';
/** /**
* @throws NotFindClassException * @throws NotFindClassException
*/ */