mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2025-12-13 03:12:47 +00:00
update vendor
This commit is contained in:
parent
1c114e0b12
commit
5ada2a732d
@ -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()) {
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user