This commit is contained in:
as2252258@163.com
2021-02-27 04:32:11 +08:00
parent 4c3b538e57
commit 1437a072c9
+6 -8
View File
@@ -41,19 +41,17 @@ class OnWorkerStart extends Callback
if (!empty($get_name) && !Snowflake::isMac()) { if (!empty($get_name) && !Snowflake::isMac()) {
swoole_set_process_name($get_name); swoole_set_process_name($get_name);
} }
Coroutine\go(function () use ($server, $worker_id) { Coroutine\go(function ($server, $worker_id) {
$sigkill = Coroutine::waitSignal(SIGTERM | SIGKILL | SIGUSR2 | SIGUSR1); $sigkill = Coroutine::waitSignal(SIGTERM | SIGKILL | SIGUSR2 | SIGUSR1);
if ($sigkill !== false) { if ($sigkill !== false) {
do { return $server->stop();
if (!Snowflake::app()->isRun()) {
break;
} }
while (Snowflake::app()->isRun()) {
Coroutine::sleep(0.01); Coroutine::sleep(0.01);
} while (true);
} }
$server->stop();; return $server->stop();
}); }, $server, $worker_id);
$name = ($worker_id >= $server->setting['worker_num'] ? 'Task' : 'Worker'); $name = ($worker_id >= $server->setting['worker_num'] ? 'Task' : 'Worker');
$this->debug(sprintf($name . ' #%d is start.....', $worker_id)); $this->debug(sprintf($name . ' #%d is start.....', $worker_id));