Resume resets in_progress jobs back to pending
This commit is contained in:
@@ -454,6 +454,23 @@ func (q *GeneralQueue) IncrementTries(ctx context.Context, jobID int, currentTri
|
||||
}
|
||||
|
||||
func (q *GeneralQueue) Resume(ctx context.Context) error {
|
||||
// Reset all in_progress jobs back to pending
|
||||
count, err := q.client.GeneralQueue.Update().
|
||||
Where(
|
||||
generalqueue.NameEQ(q.Name),
|
||||
generalqueue.StatusEQ(generalqueue.StatusInProgress),
|
||||
).
|
||||
SetStatus(generalqueue.StatusPending).
|
||||
SetUpdatedAt(time.Now()).
|
||||
Save(ctx)
|
||||
if err != nil {
|
||||
customErr := fmt.Errorf("Failed to reset in_progress jobs to pending for queue '%s': %w", q.Name, err)
|
||||
return customErr
|
||||
}
|
||||
if count > 0 {
|
||||
Debug("Reset ", count, " in_progress jobs to pending for ", q.Name, " queue")
|
||||
}
|
||||
|
||||
// Check if queue should auto-start
|
||||
if isRunning, err := q.IsRunning(ctx); err != nil {
|
||||
Error("Failed to check ", q.Name, " queue state:", err)
|
||||
|
||||
Reference in New Issue
Block a user