$http_worker = new Worker("http://0.0.0.0:23451");
$http_worker->count = 1;
$http_worker->onWorkerStart = function($worker)
{
echo "Worker starting...\n";
Timer::add(3, function()
{
$pid = pcntl_fork();
if ($pid == -1) {
} elseif ($pid==0) { //子进程$pid是0
echo '子进程2';//return ;
}
},[],true);
echo '主进程2';
return;
};
// 运行worker
Worker::runAll();
运行几十秒后,按ctrl+C结束,不会把所有子进程都关闭,会留下一些。
workerman 不支持pcntl_fork