From 98e088ecd3bfbcd2c9a6cdc3617d930fd6407fc8 Mon Sep 17 00:00:00 2001 From: daodao97 Date: Sat, 24 Oct 2020 15:52:52 +0800 Subject: [PATCH] perf: optmize cront-center --- src/cron-center/src/CrontabDispatcherProcess.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cron-center/src/CrontabDispatcherProcess.php b/src/cron-center/src/CrontabDispatcherProcess.php index a33266b..ebfac67 100644 --- a/src/cron-center/src/CrontabDispatcherProcess.php +++ b/src/cron-center/src/CrontabDispatcherProcess.php @@ -1,6 +1,7 @@ strategy = $container->get(StrategyInterface::class); $this->parser = make(Parser::class); $this->cron_manager = make(CronManager::class); + $this->config = $container->get(ConfigInterface::class); + } + + public function isEnable($server): bool + { + return $this->config->get('cron_center.enable', false); } public function handle(): void { - if (!config('cron_center.enable', false)) { - return; - } $this->event->dispatch(new CrontabDispatcherStarted()); while (true) { $this->cron_manager->createOrUpdateNode();