From 5defd5fb30ca5c99f9ef2cc711cbab174582b431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 27 Dec 2024 21:53:16 +0800 Subject: [PATCH] eee --- Processes/AbstractProcess.php | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/Processes/AbstractProcess.php b/Processes/AbstractProcess.php index c9f1dd4..6ec1463 100644 --- a/Processes/AbstractProcess.php +++ b/Processes/AbstractProcess.php @@ -6,6 +6,7 @@ namespace Kiri\Server\Processes; use Swoole\Coroutine; use Swoole\Process; use const SIGHUP; +use const SIGTERM; /** * @@ -132,10 +133,7 @@ abstract class AbstractProcess implements OnProcessInterface Coroutine::set($array); Coroutine::create(fn() => $this->coroutineWaitSignal()); } else { - pcntl_signal(\SIGTERM, [$this, 'pointWaitSignal']); - pcntl_signal(\SIGINT, [$this, 'pointWaitSignal']); - pcntl_signal(\SIGUSR1, [$this, 'pointWaitSignal']); - pcntl_signal(SIGHUP, [$this, 'pointWaitSignal']); + pcntl_signal(SIGTERM | SIGINT | SIGUSR1, [$this, 'pointWaitSignal']); } return $this; } @@ -154,21 +152,8 @@ abstract class AbstractProcess implements OnProcessInterface public function pointWaitSignal($signal): void { $this->stop = true; + $this->onSigterm(); - switch ($signal) { - case \SIGTERM: - case \SIGUSR1: - case \SIGINT: - // some stuff before stop consumer e.g. delete lock etc - pcntl_signal($signal, SIG_DFL); // restore handler - posix_kill(posix_getpid(), $signal); - break; // kill self with signal, see https://www.cons.org/cracauer/sigint.html - case SIGHUP: - // some stuff to restart consumer - break; - default: - // do nothing - } }