Describe the bug
当前user process没有显性命名,不便于查看用户自定义进程的信息
Expected behavior
提议:增加user process命名,便于显性跟踪进程信息
Screenshots
If applicable, add screenshots to help explain your problem.
Details
见代码
/**
* Add process
*
* @param Server $server
*
* @throws ServerException
*/
private function addProcesses(Server $server): void
{
$process = $server->getProcess();
file_put_contents('/tmp/record.log',json_encode($process));
if (empty($process)) {
return;
}
foreach ($process as $name => $userProcess) {
if (!$userProcess instanceof UserProcessInterface) {
throw new ServerException('Server add process must be instanceof UserProcessInterface!');
}
$callback = [$userProcess, 'run'];
$stdinOut = $userProcess->isStdinOut();
$pipeType = $userProcess->getPipeType();
$coroutine = $userProcess->isCoroutine();
$function = function (SwooleProcess $swProcess) use ($callback, $server, $name) {
$process = Process::new($swProcess);
//增加此行
Swoft\Stdlib\Helper\Sys::setProcessTitle(sprintf('swoft-process-%s', $name));
// Before
Swoft::trigger(ProcessEvent::BEFORE_USER_PROCESS, null, $server, $process, $name);
try {// Run
PhpHelper::call($callback, $process);
} catch (Throwable $e) {
Error::log('User process fail(%s %s %d)!', $e->getFile(), $e->getMessage(), $e->getLine());
}
// After
Swoft::trigger(ProcessEvent::AFTER_USER_PROCESS);
};
$currentProcess = new SwooleProcess($function, $stdinOut, $pipeType, $coroutine);
// save swoole process
$userProcess->setSwooleProcess($currentProcess);
$server->getSwooleServer()->addProcess($currentProcess);
}
}
Describe the bug 当前user process没有显性命名,不便于查看用户自定义进程的信息 Expected behavior 提议:增加user process命名,便于显性跟踪进程信息 Screenshots If applicable, add screenshots to help explain your problem.
Details 见代码