mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-03 08:22:48 +08:00
feat(timer): 新增 run_type 调度、host_id 投递和日志清理
T7: TimerBase shouldExecuteTask() - main/auto/all/manual/disabled modes
with two-phase DB row lock for auto mode
T8: TimerControllerBase - host_id param, logStart/logEnd methods
TimerServiceBase - inject host_id into site URLs
T9: TimerLogClean command - php think admin:timer:log:clean --days=30
This commit is contained in:
34
extend/base/common/command/admin/timer/TimerLogCleanBase.php
Normal file
34
extend/base/common/command/admin/timer/TimerLogCleanBase.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace base\common\command\admin\timer;
|
||||
|
||||
use app\common\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
use think\facade\Db;
|
||||
|
||||
class TimerLogCleanBase extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setName('admin:timer:log:clean')
|
||||
->addOption('days', 'd', Option::VALUE_OPTIONAL, '清理多少天前的日志', 30)
|
||||
->setDescription('清理定时器执行日志');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$days = (int) $input->getOption('days');
|
||||
$threshold = time() - ($days * 86400);
|
||||
|
||||
$count = Db::name('system_timer_log')
|
||||
->where('create_time', '<', $threshold)
|
||||
->delete();
|
||||
|
||||
$output->writeln("已清理 {$count} 条超过 {$days} 天的定时器执行日志。");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user