update vendor

This commit is contained in:
全栈小学生 2023-10-23 17:22:16 +08:00
parent 1c114e0b12
commit 5ada2a732d
3 changed files with 20 additions and 10 deletions

View File

@ -2,6 +2,7 @@
namespace yunwuxin\cron; namespace yunwuxin\cron;
use app\service\core\schedule\CoreScheduleService;
use Carbon\Carbon; use Carbon\Carbon;
use Exception; use Exception;
use think\App; use think\App;
@ -26,19 +27,23 @@ class Scheduler
public function __construct(App $app) public function __construct(App $app)
{ {
$this->app = $app; $this->app = $app;
$this->tasks = $app->config->get('cron.tasks', []); // $this->tasks = $app->config->get('cron.tasks', []);
$this->cache = $app->cache->store($app->config->get('cron.store', null)); $this->tasks = (new CoreScheduleService())->getList();
$this->cache = $app->cache->store();
} }
public function run() public function run()
{ {
$this->startedAt = Carbon::now(); $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)) { if (is_subclass_of($taskClass, Task::class)) {
/** @var Task $task */ /** @var Task $task */
$task = $this->app->invokeClass($taskClass, [$this->cache]); $task = $this->app->invokeClass($taskClass, [$task_value]);
if ($task->isDue()) { if ($task->isDue()) {
if (!$task->filtersPass()) { if (!$task->filtersPass()) {

View File

@ -36,10 +36,15 @@ abstract class Task
/** @var App */ /** @var App */
protected $app; protected $app;
public function __construct(App $app, Cache $cache) protected $vars;
public function __construct(App $app, $vars)
{ {
$this->app = $app; $this->app = $app;
$this->cache = $cache; // $this->cache = $cache;
$this->cache = $app->cache->store();
$this->vars = $vars;
$this->configure(); $this->configure();
} }

View File

@ -17,16 +17,16 @@ class Schedule extends Command
protected function execute(Input $input, Output $output) protected function execute(Input $input, Output $output)
{ {
if ('\\' == DIRECTORY_SEPARATOR) { if ('\\' == DIRECTORY_SEPARATOR) {
$command = 'start /B "' . PHP_BINARY . '" think cron:run'; $command = 'start /B "Niucloud Schedule" "' . PHP_BINARY . '" think cron:run';
} else { } else {
$command = 'nohup "' . PHP_BINARY . '" think cron:run >> /dev/null 2>&1 &'; $command = 'nohup "' . PHP_BINARY . '" think cron:run >> /dev/null 2>&1 &';
} }
$process = Process::fromShellCommandline($command); $process = Process::fromShellCommandline($command);
$output->writeln('['.date('Y-m-d H:i:s').'] Schedule:start');
while (true) { while (true) {
// $output->writeln('['.date('Y-m-d H:i:s').'] Schedule:working');
$process->run(); $process->run();
sleep(60); sleep(60);
} }