This commit is contained in:
2025-07-16 14:54:35 +08:00
parent 9376a73628
commit 37b59c8536
+11 -7
View File
@@ -71,15 +71,19 @@ class OnServerWorker extends Kiri\Server\Abstracts\Server
*/ */
public function onWorkerStart(Server $server, int $workerId): void public function onWorkerStart(Server $server, int $workerId): void
{ {
$this->dispatch->dispatch(new OnBeforeWorkerStart($server, $workerId)); try {
if ($workerId < $server->setting['worker_num']) { $this->dispatch->dispatch(new OnBeforeWorkerStart($server, $workerId));
CoordinatorManager::utility(Coordinator::WORKER_START)->waite(); if ($workerId < $server->setting['worker_num']) {
CoordinatorManager::utility(Coordinator::WORKER_START)->waite();
$this->dispatch->dispatch(new OnWorkerStart($server, $workerId)); $this->dispatch->dispatch(new OnWorkerStart($server, $workerId));
} else { } else {
$this->dispatch->dispatch(new OnTaskerStart($server, $workerId)); $this->dispatch->dispatch(new OnTaskerStart($server, $workerId));
}
$this->dispatch->dispatch(new OnAfterWorkerStart($server, $workerId));
} catch (Throwable $exception) {
Kiri::getLogger()->println(throwable($exception));
} }
$this->dispatch->dispatch(new OnAfterWorkerStart($server, $workerId));
} }