This commit is contained in:
xl
2024-08-29 17:01:07 +08:00
parent b14b18040b
commit 917e82064a
8 changed files with 34 additions and 75 deletions
+5 -12
View File
@@ -26,14 +26,6 @@ use function config;
class OnServerWorker extends Kiri\Server\Abstracts\Server
{
/**
* @var EventDispatch
*/
#[Container(EventDispatch::class)]
public EventDispatch $dispatch;
/**
* @return void
*/
@@ -68,13 +60,14 @@ class OnServerWorker extends Kiri\Server\Abstracts\Server
*/
public function onWorkerStart(Server $server, int $workerId): void
{
$this->dispatch->dispatch(new OnBeforeWorkerStart($server, $workerId));
$dispatch = Kiri::getDi()->get(EventDispatch::class);
$dispatch->dispatch(new OnBeforeWorkerStart($server, $workerId));
if ($workerId < $server->setting['worker_num']) {
$this->dispatch->dispatch(new OnWorkerStart($server, $workerId));
$dispatch->dispatch(new OnWorkerStart($server, $workerId));
} else {
$this->dispatch->dispatch(new OnTaskerStart($server, $workerId));
$dispatch->dispatch(new OnTaskerStart($server, $workerId));
}
$this->dispatch->dispatch(new OnAfterWorkerStart($server, $workerId));
$dispatch->dispatch(new OnAfterWorkerStart($server, $workerId));
}