fix: 快照前停止计划任务执行 (#1888)

pull/1890/head
ssongliu 1 year ago committed by GitHub
parent 25ccadea9e
commit ca586bb766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -145,7 +145,9 @@ func (u *SnapshotService) SnapshotCreate(req dto.SnapshotCreate) error {
} }
_ = snapshotRepo.Create(&snap) _ = snapshotRepo.Create(&snap)
go func() { go func() {
_ = global.Cron.Stop()
defer func() { defer func() {
global.Cron.Start()
_ = os.RemoveAll(rootDir) _ = os.RemoveAll(rootDir)
}() }()
fileOp := files.NewFileOp() fileOp := files.NewFileOp()
@ -254,6 +256,10 @@ func (u *SnapshotService) SnapshotRecover(req dto.SnapshotRecover) error {
_ = snapshotRepo.Update(snap.ID, map[string]interface{}{"recover_status": constant.StatusWaiting}) _ = snapshotRepo.Update(snap.ID, map[string]interface{}{"recover_status": constant.StatusWaiting})
_ = settingRepo.Update("SystemStatus", "Recovering") _ = settingRepo.Update("SystemStatus", "Recovering")
go func() { go func() {
_ = global.Cron.Stop()
defer func() {
global.Cron.Start()
}()
operation := "recover" operation := "recover"
if isReTry { if isReTry {
operation = "re-recover" operation = "re-recover"
@ -418,6 +424,10 @@ func (u *SnapshotService) SnapshotRollback(req dto.SnapshotRecover) error {
_ = settingRepo.Update("SystemStatus", "Rollbacking") _ = settingRepo.Update("SystemStatus", "Rollbacking")
_ = snapshotRepo.Update(snap.ID, map[string]interface{}{"rollback_status": constant.StatusWaiting}) _ = snapshotRepo.Update(snap.ID, map[string]interface{}{"rollback_status": constant.StatusWaiting})
go func() { go func() {
_ = global.Cron.Stop()
defer func() {
global.Cron.Start()
}()
snapJson, err := u.readFromJson(fmt.Sprintf("%s/snapshot.json", rootDir)) snapJson, err := u.readFromJson(fmt.Sprintf("%s/snapshot.json", rootDir))
if err != nil { if err != nil {
updateRollbackStatus(snap.ID, constant.StatusFailed, fmt.Sprintf("decompress file failed, err: %v", err)) updateRollbackStatus(snap.ID, constant.StatusFailed, fmt.Sprintf("decompress file failed, err: %v", err))

Loading…
Cancel
Save