We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
各位大大,ProcessBuilder 这个类可否增加支持创建多个子进程 因为我看swoft框架里面是这样的 @Process(name="getGoodProcess", coroutine=false,num=10), 但是目前组件不支持 以下是我修改后的
@Process(name="getGoodProcess", coroutine=false,num=10)
if($num > 1){ $childProcesses = []; $pid = $process->getProcess()->pid; while($num > 0){ $child = new SwooleProcess(function (SwooleProcess $child) use ($process,$pid,$processObject,$num,$name) { $child = new Process($child); $child->name($name." child process"); PhpHelper::call([$processObject, 'run'], [$child]); }); $child->name($name." manager process"); $child->start(); App::trigger(ProcessEvent::BEFORE_PROCESS, null, $name.":child:".$child->pid); $num --; $childProcesses[$pid][$child->pid] = 1; } Process::signal(SIGCHLD, function($sig) use ($childProcesses,$pid,$process,$name) { //必须为false,非阻塞模式 while(1){ $ret = Process::wait(false); if($ret){ App::trigger(ProcessEvent::AFTER_PROCESS, null, $name.":child:".$ret['pid']); unset($childProcesses[$pid][$ret['pid']]); if(!$childProcesses[$pid]){ break; } } } if($childProcesses[$pid]){ foreach ($childProcesses[$pid] as $cid=>$v){ App::trigger(ProcessEvent::AFTER_PROCESS, null, $name.":child:".$cid); } unset($childProcesses[$pid]); } $process->exit(); }); }else{ PhpHelper::call([$processObject, 'run'], [$process]); }
Originally posted by @liida in #153 (comment)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
各位大大,ProcessBuilder 这个类可否增加支持创建多个子进程
因为我看swoft框架里面是这样的
@Process(name="getGoodProcess", coroutine=false,num=10)
,但是目前组件不支持
以下是我修改后的
Originally posted by @liida in #153 (comment)
The text was updated successfully, but these errors were encountered: