From 8497df95594f9a8e31dfd4e9e8b144d7dcb02fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Mon, 21 Feb 2022 11:02:10 +0800 Subject: [PATCH] modify plugin name --- ServerCommand.php | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/ServerCommand.php b/ServerCommand.php index 0967241..c489f5a 100644 --- a/ServerCommand.php +++ b/ServerCommand.php @@ -5,14 +5,11 @@ namespace Kiri\Server; use Exception; -use Kiri\Abstracts\Config; -use Kiri\Events\EventDispatch; -use Kiri\Exception\ConfigException; use Kiri; -use Kiri\Annotation\Inject; +use Kiri\Abstracts\Config; +use Kiri\Exception\ConfigException; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; -use Swoole\Coroutine; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -30,7 +27,6 @@ class ServerCommand extends Command const ACTIONS = ['start', 'stop', 'restart']; - /** * */ @@ -58,8 +54,10 @@ class ServerCommand extends Command $manager = Kiri::app()->getServer(); $manager->setDaemon((int)!is_null($input->getOption('daemon'))); - $action = $input->getArgument('action'); - if (is_null($action)) { + $this->scan_file(); + + $action = $input->getArgument('action'); + if (is_null($action)) { throw new Exception('I don\'t know what I want to do.'); } if (!in_array($action, self::ACTIONS)) { @@ -67,12 +65,27 @@ class ServerCommand extends Command } if ($action == 'restart' || $action == 'stop') { $manager->shutdown(); - if ($action == 'stop') { - return 1; - } + if ($action == 'stop') { + return 1; + } } - $manager->start(); + $manager->start(); return 1; } + + /** + * @return void + * @throws ConfigException + * @throws \ReflectionException + */ + protected function scan_file() + { + $config = Config::get('scanner', []); + if (is_array($config)) foreach ($config as $key => $value) { + scan_directory($value, $key); + } + scan_directory(MODEL_PATH, 'app\Model'); + } + }