This commit is contained in:
2023-12-02 17:29:24 +08:00
parent 3dd4f8d4d4
commit bbfd7367d0
3 changed files with 13 additions and 4 deletions
+4 -1
View File
@@ -2,14 +2,17 @@
namespace Kiri\Server\Events;
use Swoole\Server;
class OnAfterWorkerStart
{
/**
* @param Server $server
* @param int $workerId
*/
public function __construct(public int $workerId)
public function __construct(public Server $server, public int $workerId)
{
}
+7 -1
View File
@@ -2,10 +2,16 @@
namespace Kiri\Server\Events;
use Swoole\Server;
class OnBeforeWorkerStart
{
public function __construct(public int $workerId)
/**
* @param Server $server
* @param int $workerId
*/
public function __construct(public Server $server,public int $workerId)
{
}
+2 -2
View File
@@ -68,13 +68,13 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server
*/
public function onWorkerStart(Server $server, int $workerId): void
{
$this->dispatch->dispatch(new OnBeforeWorkerStart(server: $server, workerId: $workerId));
$this->dispatch->dispatch(new OnBeforeWorkerStart($server, $workerId));
if ($workerId < $server->setting['worker_num']) {
$this->dispatch->dispatch(new OnWorkerStart($server, $workerId));
} else {
$this->dispatch->dispatch(new OnTaskerStart($server, $workerId));
}
$this->dispatch->dispatch(new OnAfterWorkerStart(workerId: $workerId));
$this->dispatch->dispatch(new OnAfterWorkerStart($server, $workerId));
}