2021-03-29 17:12:09 +08:00
|
|
|
<?php
|
|
|
|
|
|
2022-03-15 18:05:33 +08:00
|
|
|
declare(strict_types=1);
|
2021-03-29 17:12:09 +08:00
|
|
|
|
|
|
|
|
namespace ZM\Event\SwooleEvent;
|
|
|
|
|
|
2021-07-09 01:38:30 +08:00
|
|
|
use Swoole\Process;
|
2021-03-29 17:12:09 +08:00
|
|
|
use ZM\Annotation\Swoole\SwooleHandler;
|
|
|
|
|
use ZM\Event\SwooleEvent;
|
2022-03-13 22:46:22 +08:00
|
|
|
use ZM\Utils\Manager\ProcessManager;
|
2021-03-29 17:12:09 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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) {
|
2022-03-15 18:05:33 +08:00
|
|
|
if (posix_getsid($v->pid) !== false) {
|
|
|
|
|
Process::kill($v->pid, SIGTERM);
|
|
|
|
|
}
|
2021-07-09 01:38:30 +08:00
|
|
|
}
|
2022-06-08 23:11:17 +08:00
|
|
|
logger()->debug('进程 Manager 已停止!');
|
2022-05-14 23:43:15 +08:00
|
|
|
ProcessManager::removeProcessState(ZM_PROCESS_MANAGER);
|
2021-03-29 17:12:09 +08:00
|
|
|
}
|
2022-03-15 18:05:33 +08:00
|
|
|
}
|