Browse Source

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

pull/1890/head
ssongliu 1 year ago committed by GitHub
parent
commit
ca586bb766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      backend/app/service/snapshot.go

10
backend/app/service/snapshot.go

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

Loading…
Cancel
Save