From 308c992fd3e91a2966ae7d207cfcb62c50fdd414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Mon, 6 Dec 2021 11:47:12 +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 --- ServerCommand.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ServerCommand.php b/ServerCommand.php index 7a0f5ca..ad28960 100644 --- a/ServerCommand.php +++ b/ServerCommand.php @@ -4,13 +4,12 @@ declare(strict_types=1); namespace Server; -use Note\Inject; use Exception; use Kiri\Abstracts\Config; use Kiri\Events\EventDispatch; use Kiri\Exception\ConfigException; use Kiri\Kiri; -use Server\Events\OnServerBeforeStart; +use Note\Inject; use Swoole\Coroutine; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -64,12 +63,12 @@ class ServerCommand extends Command if (!in_array($input->getArgument('action'), self::ACTIONS)) { throw new Exception('I don\'t know what I want to do.'); } - if ($manager->isRunner() && $input->getArgument('action') == 'start') { - throw new Exception('Service is running. Please use restart.'); - } - $manager->shutdown(); - if ($input->getArgument('action') == 'stop') { - return 0; + $action = $input->getArgument('action'); + if ($action == 'stop' || $action == 'restart') { + $manager->shutdown(); + if ($action == 'stop') { + return 0; + } } return $this->generate_runtime_builder($manager); } @@ -105,7 +104,7 @@ class ServerCommand extends Command $this->configure_set(); Kiri::app()->getRouter()->read_files(); - + $manager->start(); return 1;