mirror of
https://github.com/truewhile/MeBox.git
synced 2026-11-16 20:54:23 +08:00
优化
This commit is contained in:
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user