Skip to content

Commit

Permalink
feat: optimize cron Code
Browse files Browse the repository at this point in the history
  • Loading branch information
bingcool committed Sep 6, 2024
1 parent eeb4046 commit 0c31f52
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Test/Scripts/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion Test/WorkerCron/conf/schedule_conf.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Test\Scripts\Kernel;

return // 定时fork进程处理任务
[
[
Expand All @@ -13,7 +15,7 @@
'extend_data' => [],
'args' => [
// 定时任务列表
'task_list' => \Test\Scripts\Kernel::buildScheduleTaskList()
'task_list' => Kernel::buildScheduleTaskList(Kernel::schedule())

// 动态定时任务列表,可以存在数据库中
// 'task_list' => function () {
Expand Down

0 comments on commit 0c31f52

Please sign in to comment.