diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/Scheduler.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/Scheduler.php index 9cf74aeec..29bc74963 100644 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/Scheduler.php +++ b/niucloud/vendor/yunwuxin/think-cron/src/cron/Scheduler.php @@ -2,6 +2,7 @@ namespace yunwuxin\cron; +use app\service\core\schedule\CoreScheduleService; use Carbon\Carbon; use Exception; use think\App; @@ -26,19 +27,23 @@ class Scheduler public function __construct(App $app) { $this->app = $app; - $this->tasks = $app->config->get('cron.tasks', []); - $this->cache = $app->cache->store($app->config->get('cron.store', null)); +// $this->tasks = $app->config->get('cron.tasks', []); + $this->tasks = (new CoreScheduleService())->getList(); + + $this->cache = $app->cache->store(); } public function run() { $this->startedAt = Carbon::now(); - foreach ($this->tasks as $taskClass) { + $file = root_path('runtime').'.schedule'; + file_put_contents($file, time()); + $taskClass = 'app\command\schedule\Schedule'; + foreach ($this->tasks as $task_value) { if (is_subclass_of($taskClass, Task::class)) { - /** @var Task $task */ - $task = $this->app->invokeClass($taskClass, [$this->cache]); + $task = $this->app->invokeClass($taskClass, [$task_value]); if ($task->isDue()) { if (!$task->filtersPass()) { diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/Task.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/Task.php index 5f491e826..de4e08a84 100644 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/Task.php +++ b/niucloud/vendor/yunwuxin/think-cron/src/cron/Task.php @@ -36,10 +36,15 @@ abstract class Task /** @var App */ protected $app; - public function __construct(App $app, Cache $cache) + protected $vars; + + public function __construct(App $app, $vars) { + $this->app = $app; - $this->cache = $cache; +// $this->cache = $cache; + $this->cache = $app->cache->store(); + $this->vars = $vars; $this->configure(); } diff --git a/niucloud/vendor/yunwuxin/think-cron/src/cron/command/Schedule.php b/niucloud/vendor/yunwuxin/think-cron/src/cron/command/Schedule.php index edeea6041..6ffc7594c 100644 --- a/niucloud/vendor/yunwuxin/think-cron/src/cron/command/Schedule.php +++ b/niucloud/vendor/yunwuxin/think-cron/src/cron/command/Schedule.php @@ -17,16 +17,16 @@ class Schedule extends Command protected function execute(Input $input, Output $output) { - if ('\\' == DIRECTORY_SEPARATOR) { - $command = 'start /B "' . PHP_BINARY . '" think cron:run'; + $command = 'start /B "Niucloud Schedule" "' . PHP_BINARY . '" think cron:run'; } else { $command = 'nohup "' . PHP_BINARY . '" think cron:run >> /dev/null 2>&1 &'; } $process = Process::fromShellCommandline($command); - + $output->writeln('['.date('Y-m-d H:i:s').'] Schedule:start'); while (true) { +// $output->writeln('['.date('Y-m-d H:i:s').'] Schedule:working'); $process->run(); sleep(60); }