This commit is contained in:
2026-07-08 09:42:56 +08:00
parent 0adfe14a1f
commit 7f36bb0d53
5 changed files with 78 additions and 12 deletions
+9 -4
View File
@@ -9,7 +9,6 @@ use Kiri\Exception\NotFindClassException;
use Kiri\Server\Config as SConfig;
use Kiri\Server\Constant;
use Kiri\Server\Events\OnServerBeforeStart;
use Kiri\Server\Events\OnShutdown;
use Kiri\Server\Handler\OnServer;
use Kiri\Server\Processes\TraitProcess;
use Kiri\Server\ServerInterface;
@@ -32,6 +31,8 @@ class AsyncServer extends Component implements ServerInterface
*/
private ?Server $server = null;
private bool $shuttingDown = false;
/**
* @param array $service
@@ -61,14 +62,18 @@ class AsyncServer extends Component implements ServerInterface
*/
public function shutdown(): bool
{
$this->server->shutdown();
if ($this->shuttingDown) {
return true;
}
$this->shuttingDown = true;
$this->dispatch->dispatch(new OnShutdown);
if ($this->server !== null) {
$this->server->shutdown();
}
return true;
}
/**
* @param array $service
* @param int $daemon