Skip to content

Commit

Permalink
Merge pull request #352 from bcgov/yj
Browse files Browse the repository at this point in the history
chore: commented remove stalled jobs
  • Loading branch information
ychung-mot authored May 31, 2024
2 parents aef5df1 + b32c23a commit 870a99e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions server/StrDss.Service/Hangfire/SkipSameJobAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ public void OnCreating(CreatingContext context)
var job = context.Job;
var jobFingerprint = GetJobFingerprint(job);

//delete stalled jobs
var monitor = context.Storage.GetMonitoringApi();
var allJobs = monitor.ProcessingJobs(0, 999999999);
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);
}
}
//delete stalled jobs
//var allJobs = monitor.ProcessingJobs(0, 999999999);
//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);
// }
//}

//skip same job
var fingerprints = monitor.ProcessingJobs(0, 999999999)
Expand Down

0 comments on commit 870a99e

Please sign in to comment.