This commit is contained in:
xl
2024-09-04 11:21:12 +08:00
parent 90154ece54
commit 9b22f66571
2 changed files with 4 additions and 12 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ class OnServerWorker extends Kiri\Server\Abstracts\Server
*/ */
protected function processName(Server $server, string $prefix): void protected function processName(Server $server, string $prefix): void
{ {
Kiri::setProcessName(sprintf($prefix . ' AbstractProcess[%d].%d', $server->worker_pid, $server->worker_id)); Kiri::setProcessName(sprintf($prefix . ' Process[%d].%d', $server->worker_pid, $server->worker_id));
} }
+3 -11
View File
@@ -22,21 +22,13 @@ trait TraitProcess
*/ */
public function addProcess(string|array|AbstractProcess $class): void public function addProcess(string|array|AbstractProcess $class): void
{ {
if (!is_array($class)) { if (!is_array($class)) $class = [$class];
$class = [$class];
}
foreach ($class as $name) { foreach ($class as $name) {
if (is_string($name)) { if (is_string($name)) $name = Kiri::getDi()->get($name);
$name = Kiri::getDi()->get($name);
}
if (isset($this->_process[$name->getName()])) { if (isset($this->_process[$name->getName()])) {
throw new Exception('AbstractProcess(' . $name->getName() . ') is exists.'); throw new Exception('AbstractProcess(' . $name->getName() . ') is exists.');
} }
$process = $this->genProcess($name); $this->_process[$name->getName()] = $this->genProcess($name);
if ($name->isEnableQueue()) {
$process->useQueue();
}
$this->_process[$name->getName()] = $process;
} }
} }