From 01415cf6a2261868f8496acfc643ecaf9ad4fd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 7 Sep 2020 18:35:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Action.php | 9 ++++++++- System/Application.php | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/HttpServer/Action.php b/HttpServer/Action.php index 46f2d14b..8235150e 100644 --- a/HttpServer/Action.php +++ b/HttpServer/Action.php @@ -5,6 +5,8 @@ namespace HttpServer; use Exception; +use Snowflake\Abstracts\Input; +use Snowflake\Exception\ComponentException; use Snowflake\Snowflake; use Swoole\WebSocket\Server; @@ -28,7 +30,6 @@ trait Action } - /** * @param \HttpServer\Server $socket * @throws Exception @@ -97,9 +98,15 @@ trait Action /** * @param $port * @return bool|array + * @throws ComponentException */ private function isUse($port) { + /** @var Input $input */ + $input = Snowflake::app()->get('input'); + if (in_array($input->get('action'), ['start', 'restart'])) { + return true; + } if (empty($port)) { return false; } diff --git a/System/Application.php b/System/Application.php index 265eec01..a534a02f 100644 --- a/System/Application.php +++ b/System/Application.php @@ -83,6 +83,7 @@ class Application extends BaseApplication */ public function start(Input $argv) { + $this->set('input', $argv); $manager = Snowflake::app()->server; $manager->setDaemon($argv->get('daemon', 0)); switch ($argv->get('action')) {