Skip to content
Snippets Groups Projects
Verified Commit 64db5568 authored by 贾昊's avatar 贾昊
Browse files

Parallel: 优化日志: 日志中显示子进程ID

parent db1b7a14
Branches
Tags
No related merge requests found
......@@ -58,7 +58,7 @@ class Promise
}
// Master
$worker->setPID($pid);
$this->logger->info(sprintf("%s: Worker(%s) created", __METHOD__, strval($worker)));
$this->logger->info(sprintf("%s: Worker(%s,pid=%d) created", __METHOD__, $worker, $pid));
}
// 等待worker结束
......@@ -72,8 +72,8 @@ class Promise
foreach ($this->workers as $idx => $worker) {
if ($worker->getPID() == $pid) {
$worker->setReturnCode(pcntl_wexitstatus($status));
$this->logger->info(sprintf("%s: Worker(%s) finished with code %d",
__METHOD__, strval($worker), $worker->getReturnCode()));
$this->logger->info(sprintf("%s: Worker(%s,pid=%d) finished with code %d",
__METHOD__, $worker, $worker->getPID(), $worker->getReturnCode()));
unset($this->workers[$idx]);
yield $worker;
}
......@@ -99,7 +99,7 @@ class Promise
}
posix_kill($worker->getPID(), SIGKILL);
$worker->setReturnCode(ISchoolError::ERRNO_TIMEOUT);
$this->logger->error(sprintf("%s: Worker(%s) killed", __METHOD__, strval($worker)));
$this->logger->error(sprintf("%s: Worker(%s) killed", __METHOD__, $worker));
}
if ($sig_no > 0) {
exit($sig_no);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment