From 0c31f52198404887b71e6cb392b354d394f33f58 Mon Sep 17 00:00:00 2001 From: bingcool <2437667702@qq.com> Date: Fri, 6 Sep 2024 19:48:49 +0800 Subject: [PATCH] feat: optimize cron Code --- Test/Scripts/Kernel.php | 4 ++-- Test/WorkerCron/conf/schedule_conf.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Test/Scripts/Kernel.php b/Test/Scripts/Kernel.php index 538f1496..389aead9 100644 --- a/Test/Scripts/Kernel.php +++ b/Test/Scripts/Kernel.php @@ -45,12 +45,12 @@ public static function schedule() * * @return array */ - public static function buildScheduleTaskList() + public static function buildScheduleTaskList(Schedule $schedule) { $appName = $_SERVER['argv'][2]; $scheduleList = []; - foreach (self::schedule()->toArray() as $item) { + foreach ($schedule->toArray() as $item) { $item['exec_bin_file'] = SystemEnv::PhpBinFile(); if (!isset($item['fork_type'])) { $item['fork_type'] = CronForkProcess::FORK_TYPE_PROC_OPEN; diff --git a/Test/WorkerCron/conf/schedule_conf.php b/Test/WorkerCron/conf/schedule_conf.php index 154e1cec..cc0855e9 100644 --- a/Test/WorkerCron/conf/schedule_conf.php +++ b/Test/WorkerCron/conf/schedule_conf.php @@ -1,5 +1,7 @@ [], 'args' => [ // 定时任务列表 - 'task_list' => \Test\Scripts\Kernel::buildScheduleTaskList() + 'task_list' => Kernel::buildScheduleTaskList(Kernel::schedule()) // 动态定时任务列表,可以存在数据库中 // 'task_list' => function () {