Files
zhamao-framework/src/ZM/Event/SwooleEvent/OnManagerStop.php

30 lines
667 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace ZM\Event\SwooleEvent;
2021-07-09 01:38:30 +08:00
use Swoole\Process;
use ZM\Annotation\Swoole\SwooleHandler;
use ZM\Console\Console;
use ZM\Event\SwooleEvent;
2022-03-13 22:46:22 +08:00
use ZM\Utils\Manager\ProcessManager;
/**
* Class OnManagerStop
* @SwooleHandler("ManagerStop")
*/
class OnManagerStop implements SwooleEvent
{
2022-03-13 22:46:22 +08:00
public function onCall()
{
foreach (ProcessManager::$user_process as $v) {
if (posix_getsid($v->pid) !== false) {
Process::kill($v->pid, SIGTERM);
}
2021-07-09 01:38:30 +08:00
}
Console::verbose('进程 Manager 已停止!');
ProcessManager::removeProcessState(ZM_PROCESS_MANAGER);
}
}