think-swoole用swoole5运行提示错误怎么解决
这是来自热更新提示的错误
[FATAL ERROR]: all coroutines (count: 1) are asleep - deadlock!
差不多就是这个信息。
但是用swoole4版本提示
[2024-06-23 08:42:53 @19761.0] INFO reload workers
这种信息
// 整理了一下,基本就是下面这种代码
$pool = new Pool(2, 1, 0, true);
$pool->on(Constant::EVENT_WORKER_START, function ($pool, $workerId) {
Process::signal(SIGTERM, function () use ($pool) {
$pool->getProcess()->exit();
});
if ($workerId == 0) {
$http = new Server('0.0.0.0', 8000, false, true);
$http->handle('/', function ($request, $response) use ($workerId) {
Coroutine::create(function () use ($workerId, $response) {
$response->end("1");
});
});
$http->start();
} else {
Timer::tick(2000, function () use ($pool) {
Process::kill($pool->master_pid, SIGUSR1);
});
}
});
$pool->start();