修复worker等待状态bug
This commit is contained in:
parent
ea32a4cd33
commit
104ad3f744
@ -129,7 +129,6 @@ class ManageProcess
|
||||
// 向 process 投递 cron
|
||||
// var_dump(serialize($cron));
|
||||
//$process->push(serialize($cron));
|
||||
var_dump($process->pop());
|
||||
} else {
|
||||
// 创建临时 process 处理,处理完自动销毁
|
||||
$this->createProcess($cron);
|
||||
@ -183,6 +182,8 @@ class ManageProcess
|
||||
*/
|
||||
protected function initProcesses()
|
||||
{
|
||||
file_put_contents($this->getProcessStatusPath(), '');
|
||||
|
||||
for ($i = 0; $i < $this->staticNum; $i++) {
|
||||
|
||||
$process = $this->createStaticProcess();
|
||||
|
@ -94,12 +94,14 @@ trait Process
|
||||
|
||||
// 获取等待状态的 worker
|
||||
$processes = $this->getProcessesStatus();
|
||||
// $processIds
|
||||
foreach ($processes as $process) {
|
||||
if ($process['status'] == self::WAITING) {
|
||||
$pid = $process['pid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取相应的状态
|
||||
if (isset($this->processes[$pid])) {
|
||||
return [true, $this->processes[$pid]];
|
||||
|
@ -35,9 +35,11 @@ trait Store
|
||||
*/
|
||||
public function storeStatus(array $status)
|
||||
{
|
||||
if (file_exists($this->getProcessStatusPath())) {
|
||||
|
||||
$workersStatus = $this->getProcessesStatus();
|
||||
$workersStatus = $this->getProcessesStatus();
|
||||
if (empty($workersStatus)) {
|
||||
$this->writeStatusToFile([$status]);
|
||||
} else {
|
||||
// ['PID',, 'START_AT', 'STATUS', 'DEAL_TASKS', 'ERRORS', 'running_time', 'memory'];
|
||||
$pids = array_column($workersStatus, 'pid');
|
||||
|
||||
@ -52,8 +54,6 @@ trait Store
|
||||
}
|
||||
}
|
||||
$this->writeStatusToFile($workersStatus);
|
||||
} else {
|
||||
file_put_contents($this->getProcessStatusPath(), \json_encode([$status]));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user