This commit is contained in:
2021-08-17 18:38:38 +08:00
parent 1cb36c8707
commit 4ab955d399
2 changed files with 11 additions and 2 deletions
+2 -2
View File
@@ -9,9 +9,9 @@ class OnShutdown
/**
* @param Server $server
* @param Server|null $server
*/
public function __construct(Server $server)
public function __construct(?Server $server = null)
{
}
+9
View File
@@ -3,17 +3,20 @@
namespace Http;
use Annotation\Inject;
use Exception;
use Http\Abstracts\HttpService;
use JetBrains\PhpStorm\Pure;
use Kiri\Abstracts\Config;
use Kiri\Error\LoggerProcess;
use Kiri\Events\EventDispatch;
use Kiri\Exception\ConfigException;
use Kiri\Exception\NotFindClassException;
use Kiri\Process\Biomonitoring;
use ReflectionException;
use Rpc\Service;
use Server\Constant;
use Server\Events\OnShutdown;
use Server\ServerManager;
use Swoole\Runtime;
@@ -37,6 +40,11 @@ class Server extends HttpService
private mixed $daemon = 0;
/** @var EventDispatch */
#[Inject(EventDispatch::class)]
public EventDispatch $eventDispatch;
/**
*
*/
@@ -126,6 +134,7 @@ class Server extends HttpService
foreach ($configs['ports'] ?? [] as $config) {
$this->manager->stopServer($config['port']);
}
$this->eventDispatch->dispatch(new OnShutdown());
}