0
while ($result = \swoole_process::wait(false)) {
    $pid = $result['pid'];
    $exitCode = $result['code'];
    // 信号函数能直接共享主进程的内容
    $cmd = $this->works[$pid]['cmd'];
    list($outFile, $errorFile, $statusFile, $reportFile) = $this->getOutputFiles($pid);

    // 错误中断日志记录
    if (15 == $exitCode || 143 == $exitCode) {
        $tailMessage = "\n\n$pid : 当前进程是被kill掉的\n";
        $tailMessage .= "--------------tail out-------------\n";
        $tailMessage .= shell_exec("tail $outFile");
        $tailMessage .= "--------------tail out-------------\n";
        $tailMessage .= "\n";
        file_put_contents($errorFile, $tailMessage, FILE_APPEND);
    }
}

虽然说swoole_process::wait()返回了code码,例如

zhgxun-pro:zoulu zhgxun$ ./yii etl/default/test
Array
(
    [pid] => 22061
    [code] => 0
    [signal] => 0
)
Terminated: 15
zhgxun-pro:zoulu zhgxun$

如此操作是无效的,但是退出码15或143这样的操作,使用swoole_process应该怎么来捕捉呢?

广训 328
2017-03-26 提问
0 个回答

撰写答案

推广链接