Skip to content

Commit

Permalink
chore: deleting stalled job
Browse files Browse the repository at this point in the history
  • Loading branch information
ychung-mot committed May 31, 2024
1 parent 3497bc8 commit b7044c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/StrDss.Service/Hangfire/SkipSameJobAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ public void OnCreating(CreatingContext context)
//delete stalled jobs
var monitor = context.Storage.GetMonitoringApi();
var allJobs = monitor.ProcessingJobs(0, 999999999);
var cutoffTime = DateTime.UtcNow.AddMinutes(-10);
var cutoffTime = DateTime.UtcNow.AddHours(-12);

foreach (var processingJob in allJobs)
{
if (processingJob.Value.StartedAt < cutoffTime)
{
Console.WriteLine($"[Hangfire] Deleting stalled job: {processingJob.Key} {processingJob.Value.InProcessingState} ");
BackgroundJob.Delete(processingJob.Key);
}
}
Expand Down

0 comments on commit b7044c5

Please sign in to comment.