diff --git a/internal/service/task.go b/internal/service/task.go index b4a6bcc..38553a0 100644 --- a/internal/service/task.go +++ b/internal/service/task.go @@ -9,7 +9,6 @@ import ( "path/filepath" "strings" "sync" - "time" "3588AdminBackend/internal/config" "3588AdminBackend/internal/models" @@ -308,26 +307,13 @@ func (s *TaskService) executeOnDevice(task *models.Task, did string) { s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, "invalid payload: "+err.Error()) return } - // Retry config apply up to 3 times (media-server may be slow to reload). - var lastErr error - var lastCode int - for attempt := 0; attempt < 3; attempt++ { - if attempt > 0 { - time.Sleep(time.Duration(attempt) * 3 * time.Second) - s.updateDeviceStatus(task.ID, did, models.TaskRunning, float64(attempt)/3.0, fmt.Sprintf("重试 %d/2", attempt)) - } - _, code, err := s.agent.Do("PUT", dev.IP, dev.AgentPort, "/v1/config", body) - if err == nil && code < 400 { - lastErr = nil; lastCode = code; break - } - lastErr = err; lastCode = code - } - if lastErr != nil { - s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, lastErr.Error()) + _, code, err := s.agent.Do("PUT", dev.IP, dev.AgentPort, "/v1/config", body) + if err != nil { + s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, err.Error()) return } - if lastCode >= 400 { - s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, fmt.Sprintf("agent error: %d", lastCode)) + if code >= 400 { + s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, fmt.Sprintf("agent error: %d", code)) return } s.updateDeviceStatus(task.ID, did, models.TaskSuccess, 1.0, "")