From f371589935677aaaaaacbb7e56989e3904d13cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 19 Aug 2021 15:36:59 +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 --- System/Application.php | 23 ++++++++++++++++++++--- http-helper/Server.php | 1 - 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/System/Application.php b/System/Application.php index e76f0716..09424c50 100644 --- a/System/Application.php +++ b/System/Application.php @@ -11,11 +11,13 @@ namespace Kiri; use Closure; +use Console\CommandInterface; use Console\Console; use Console\ConsoleProviders; use Database\DatabasesProviders; use Exception; use Http\Context\Response; +use Http\Server; use Http\ServerProviders; use Kiri\Abstracts\BaseApplication; use Kiri\Abstracts\Config; @@ -86,6 +88,8 @@ class Application extends BaseApplication { $manager = di(ServerManager::class); $manager->addProcess(FileChangeCustomProcess::class); + + putenv('enableFileChange=on'); } @@ -161,14 +165,14 @@ class Application extends BaseApplication * @return void * @throws Exception */ - public function start(Input $argv): void + public function execute(Input $argv): void { try { - /** @var Console $manager */ $manager = Kiri::app()->get('console'); - $manager->register(Runtime::class); $class = $manager->setParameters($argv)->search(); + $this->enableFileChange($class); + $data = $this->getBuilder($manager->exec($class)); } catch (\Throwable $exception) { $data = $this->getBuilder(logger()->exception($exception)); @@ -179,6 +183,19 @@ class Application extends BaseApplication } + /** + * @throws NotFindClassException + * @throws ReflectionException + */ + private function enableFileChange($class): void + { + $this->register(Runtime::class); + if (env('enableFileChange', 'off') == 'off' || !($class instanceof Server)) { + scan_directory(directory('app'), 'App'); + } + } + + /** * @param $data * @return Response|ResponseInterface diff --git a/http-helper/Server.php b/http-helper/Server.php index 28738d94..719190dc 100644 --- a/http-helper/Server.php +++ b/http-helper/Server.php @@ -30,7 +30,6 @@ class Server extends HttpService { private array $process = [ - Biomonitoring::class, LoggerProcess::class ];