This commit is contained in:
2026-07-08 09:42:56 +08:00
parent 0adfe14a1f
commit 7f36bb0d53
5 changed files with 78 additions and 12 deletions
+13 -2
View File
@@ -42,15 +42,26 @@ trait TraitServer
*/
public function onSigint($no, array $signInfo): void
{
static $handling = false;
if ($handling) {
return;
}
$handling = true;
try {
$pidFile = function_exists('storage') ? storage('.swoole.pid') : '';
$masterPid = is_file($pidFile) ? (int)trim((string)file_get_contents($pidFile)) : 0;
if ($masterPid > 1 && $masterPid !== getmypid()) {
return;
}
Kiri::getLogger()->alert('Pid ' . getmypid() . ' get signo ' . $no);
$this->shutdown();
} catch (\Throwable $exception) {
\Kiri::getLogger()->json_log($exception);
\Kiri::getLogger()->json_log($exception);
}
}
/**
* @param $signal
* @param $callback