modify
This commit is contained in:
@@ -36,28 +36,31 @@ class OnWorkerStart extends Callback
|
|||||||
*/
|
*/
|
||||||
public function onHandler(Server $server, int $worker_id): void
|
public function onHandler(Server $server, int $worker_id): void
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
// }
|
||||||
]);
|
// ]);
|
||||||
$get_name = $this->get_process_name($server, $worker_id);
|
$get_name = $this->get_process_name($server, $worker_id);
|
||||||
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 (Server $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) {
|
return Process::kill($server->worker_pid);
|
||||||
// return $server->stop();
|
}
|
||||||
// }
|
do {
|
||||||
// while (Snowflake::app()->isRun()) {
|
$number = Coroutine::stats()['coroutine_num'];
|
||||||
// Coroutine::sleep(0.01);
|
if ($number === 0) {
|
||||||
// }
|
break;
|
||||||
// return $server->stop();
|
}
|
||||||
// }, $server, $worker_id);
|
Coroutine::sleep(0.01);
|
||||||
|
} while (true);
|
||||||
|
return Process::kill($server->worker_pid);
|
||||||
|
}, $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));
|
||||||
|
|||||||
Reference in New Issue
Block a user