This commit is contained in:
truewhile
2026-11-12 18:58:45 +08:00
parent 79943d9067
commit d7c150ffd9
29 changed files with 4158 additions and 5 deletions
+17
View File
@@ -55,6 +55,9 @@ type SchedulerService struct {
segments *MediaSegmentService
backup *BackupService
// cloudDownload 用于周期轮询 115 云下载任务状态(nil 表示不启用)。
cloudDownload *CloudDownloadService
mu sync.Mutex
stopCh chan struct{}
jobs []*scheduledJob
@@ -73,6 +76,11 @@ func (s *SchedulerService) SetBackupService(backup *BackupService) {
s.backup = backup
}
// SetCloudDownload 注入云下载服务:注入后才注册轮询任务。
func (s *SchedulerService) SetCloudDownload(cd *CloudDownloadService) {
s.cloudDownload = cd
}
func (s *SchedulerService) SetOrganizePipeline(pipeline *OrganizePipelineService) {
s.organizePipeline = pipeline
}
@@ -213,6 +221,15 @@ func (s *SchedulerService) Start(ctx context.Context) {
run: s.jobDatabaseBackup,
})
}
// 云下载轮询:只有注入了云下载服务才注册,避免旧部署跑空转任务。
// 间隔可配(cloud_download.poll_interval_sec),由服务自己读取。
if s.cloudDownload != nil {
s.jobs = append(s.jobs, &scheduledJob{
name: "cloud_download_poll",
interval: s.cloudDownload.pollInterval(),
run: s.jobCloudDownloadPoll,
})
}
for _, j := range s.jobs {
initialDelay := 15 * time.Second
if j.name == "library_scan" || j.name == "organize_source" || j.name == "segment_prewarm" {