2021-03-29 15:34:24 +08:00
|
|
|
<?php /** @noinspection PhpUnusedParameterInspection */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace ZM\Event\SwooleEvent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Swoole\Server;
|
|
|
|
|
use Swoole\Timer;
|
|
|
|
|
use ZM\Annotation\Swoole\SwooleHandler;
|
2021-07-04 15:45:30 +08:00
|
|
|
use ZM\ConnectionManager\ManagerGM;
|
2021-03-29 15:34:24 +08:00
|
|
|
use ZM\Console\Console;
|
|
|
|
|
use ZM\Event\SwooleEvent;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class OnWorkerExit
|
|
|
|
|
* @package ZM\Event\SwooleEvent
|
|
|
|
|
* @SwooleHandler("WorkerExit")
|
|
|
|
|
*/
|
|
|
|
|
class OnWorkerExit implements SwooleEvent
|
|
|
|
|
{
|
|
|
|
|
public function onCall(Server $server, $worker_id) {
|
|
|
|
|
Timer::clearAll();
|
2021-07-04 15:45:30 +08:00
|
|
|
foreach($server->connections as $v) {
|
|
|
|
|
$server->close($v);
|
|
|
|
|
Console::info("Closing connection #".$v);
|
|
|
|
|
}
|
2021-03-29 15:34:24 +08:00
|
|
|
Console::info("正在结束 Worker #".$worker_id.",进程内可能有事务在运行...");
|
|
|
|
|
}
|
|
|
|
|
}
|