This commit is contained in:
as2252258@163.com
2021-02-27 05:04:04 +08:00
parent 1c16c6af4c
commit c70dcae26c
+5 -6
View File
@@ -39,9 +39,9 @@ class OnWorkerStart extends Callback
{ {
Coroutine::set([ Coroutine::set([
'enable_deadlock_check' => false, 'enable_deadlock_check' => false,
// 'exit_condition' => function () { // 'exit_condition' => function () {
// return Coroutine::stats()['coroutine_num'] === 0; // return Coroutine::stats()['coroutine_num'] === 0;
// } // }
]); ]);
putenv('workerId=' . $worker_id); putenv('workerId=' . $worker_id);
@@ -62,7 +62,6 @@ class OnWorkerStart extends Callback
} }
/** /**
* @param $server * @param $server
* @param $worker_id * @param $worker_id
@@ -72,7 +71,7 @@ class OnWorkerStart extends Callback
Coroutine\go(function (Server $server, $worker_id) { Coroutine\go(function (Server $server, $worker_id) {
$sigkill = Coroutine::waitSignal(SIGTERM | SIGKILL | SIGUSR2 | SIGUSR1); $sigkill = Coroutine::waitSignal(SIGTERM | SIGKILL | SIGUSR2 | SIGUSR1);
if ($sigkill !== false) { if ($sigkill !== false) {
return $server->stop(); return $server->stop(-1, true);
} }
do { do {
$number = Co::stats()['coroutine_num']; $number = Co::stats()['coroutine_num'];
@@ -82,7 +81,7 @@ class OnWorkerStart extends Callback
} }
Coroutine::sleep(0.01); Coroutine::sleep(0.01);
} while (true); } while (true);
return $server->stop(); return $server->stop(-1, true);
}, $server, $worker_id); }, $server, $worker_id);
} }