#feature: add Jenkins deploy monitor & log clean task

This commit is contained in:
2026-01-19 11:46:38 +08:00
parent 381d5e6e49
commit da3b05b7c0
22 changed files with 968 additions and 80 deletions

View File

@@ -25,16 +25,16 @@ Schedule::command('git-monitor:check')
->everyTenMinutes()
->withoutOverlapping()
->runInBackground()
->name('git-monitor-check')
->description('Git 监控 - 检查 release 分支变化')
->description('git-monitor-check')
->appendOutputTo(storage_path('logs/scheduled-tasks/git-monitor-' . date('Y-m-d') . '.log'))
->when(fn() => \App\Services\ScheduledTaskService::isEnabled('git-monitor-check'));
// Git Monitor - 每天凌晨 2 点刷新 release 缓存
Schedule::command('git-monitor:cache')
->dailyAt('02:00')
->withoutOverlapping()
->name('git-monitor-cache')
->description('Git 监控 - 刷新 release 缓存')
->description('git-monitor-cache')
->appendOutputTo(storage_path('logs/scheduled-tasks/git-monitor-' . date('Y-m-d') . '.log'))
->when(fn() => \App\Services\ScheduledTaskService::isEnabled('git-monitor-cache'));
// SLS 日志分析 - 每天凌晨 2 点执行
@@ -42,8 +42,8 @@ Schedule::command('log-analysis:run --from="-24h" --to="now" --query="ERROR or W
->dailyAt('02:00')
->withoutOverlapping()
->runInBackground()
->name('daily-log-analysis')
->description('SLS 日志分析 - 每日分析过去 24 小时日志')
->description('daily-log-analysis')
->appendOutputTo(storage_path('logs/scheduled-tasks/log-analysis-' . date('Y-m-d') . '.log'))
->when(fn() => \App\Services\ScheduledTaskService::isEnabled('daily-log-analysis'))
->onFailure(fn() => Log::error('每日日志分析定时任务执行失败'));
@@ -52,7 +52,32 @@ Schedule::command('log-analysis:run --from="-6h" --to="now" --query="ERROR or WA
->everyFourHours()
->withoutOverlapping()
->runInBackground()
->name('frequent-log-analysis')
->description('SLS 日志分析 - 定期分析过去 6 小时日志')
->description('frequent-log-analysis')
->appendOutputTo(storage_path('logs/scheduled-tasks/log-analysis-' . date('Y-m-d') . '.log'))
->when(fn() => \App\Services\ScheduledTaskService::isEnabled('frequent-log-analysis'))
->onFailure(fn() => Log::error('SLS 日志分析定时任务执行失败'));
// Jenkins Monitor - 每分钟检查新构建
Schedule::command('jenkins:monitor')
->everyMinute()
->withoutOverlapping()
->runInBackground()
->description('jenkins-monitor')
->appendOutputTo(storage_path('logs/scheduled-tasks/jenkins-monitor-' . date('Y-m-d') . '.log'))
->when(fn() => \App\Services\ScheduledTaskService::isEnabled('jenkins-monitor'));
// 定时任务刷新 - 每天凌晨 3 点刷新定时任务列表
Schedule::command('scheduled-task:refresh')
->dailyAt('03:00')
->withoutOverlapping()
->description('scheduled-task-refresh')
->appendOutputTo(storage_path('logs/scheduled-tasks/scheduled-tasks-' . date('Y-m-d') . '.log'))
->when(fn() => \App\Services\ScheduledTaskService::isEnabled('scheduled-task-refresh'));
// 日志清理 - 每天凌晨 4 点清理 7 天前的定时任务日志
Schedule::command('logs:clean-scheduled-tasks --days=7')
->dailyAt('04:00')
->withoutOverlapping()
->description('logs-cleanup')
->appendOutputTo(storage_path('logs/scheduled-tasks/scheduled-tasks-' . date('Y-m-d') . '.log'))
->when(fn() => \App\Services\ScheduledTaskService::isEnabled('logs-cleanup'));