This commit is contained in:
@@ -107,7 +107,7 @@ namespace AyaNova.Biz
|
||||
//All items have an event date, for non time delayed events it's just the moment it was created
|
||||
//which will predate this moment now if it's pre-existing
|
||||
var events = await ct.NotifyEvent.Include(z => z.NotifySubscription).ToListAsync();
|
||||
log.LogDebug($"Found {events.Count} NotifyEvents to examine for potential delivery");
|
||||
log.LogTrace($"Found {events.Count} NotifyEvents to examine for potential delivery");
|
||||
|
||||
//cache translations
|
||||
//Get all subscription unique userId's that aren't inapp deliveries
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("CoreJobSweeper");
|
||||
private static DateTime lastSweep = DateTime.MinValue;
|
||||
private static TimeSpan SWEEP_EVERY_INTERVAL = new TimeSpan(0, 30, 0);
|
||||
private static TimeSpan SWEEP_EVERY_INTERVAL = new TimeSpan(0, 0, 10);
|
||||
private static TimeSpan SUCCEEDED_JOBS_DELETE_AFTER_THIS_TIMESPAN = new TimeSpan(14, 0, 0, 0);//14 days
|
||||
private static TimeSpan FAILED_JOBS_DELETE_AFTER_THIS_TIMESPAN = new TimeSpan(14, 0, 0, 0);//14 days (gives people time to notice and look into it)
|
||||
private static TimeSpan INTERNAL_JOBS_LOGS_DELETE_AFTER_THIS_TIMESPAN = new TimeSpan(14, 0, 0, 0);//14 days
|
||||
@@ -28,7 +28,7 @@ namespace AyaNova.Biz
|
||||
// DoSweep
|
||||
//
|
||||
public static async Task DoWorkAsync()
|
||||
{
|
||||
{
|
||||
//This will get triggered roughly every minute, but we don't want to sweep that frequently
|
||||
if (DateTime.UtcNow - lastSweep < SWEEP_EVERY_INTERVAL)
|
||||
return;
|
||||
@@ -40,22 +40,31 @@ namespace AyaNova.Biz
|
||||
//calculate cutoff to delete
|
||||
DateTime dtDeleteCutoff = DateTime.UtcNow - SUCCEEDED_JOBS_DELETE_AFTER_THIS_TIMESPAN;
|
||||
await sweepAsync(ct, dtDeleteCutoff, JobStatus.Completed);
|
||||
|
||||
|
||||
//SWEEP FAILED JOBS
|
||||
//calculate cutoff to delete
|
||||
dtDeleteCutoff = DateTime.UtcNow - FAILED_JOBS_DELETE_AFTER_THIS_TIMESPAN;
|
||||
await sweepAsync(ct, dtDeleteCutoff, JobStatus.Failed);
|
||||
|
||||
|
||||
//KILL STUCK JOBS
|
||||
//calculate cutoff to delete
|
||||
DateTime dtRunningDeadline = DateTime.UtcNow - RUNNING_JOBS_BECOME_FAILED_AFTER_THIS_TIMESPAN;
|
||||
await killStuckJobsAsync(ct, dtRunningDeadline);
|
||||
|
||||
|
||||
//SWEEP INTERNAL JOB LOG
|
||||
//calculate cutoff to delete
|
||||
dtDeleteCutoff = DateTime.UtcNow - INTERNAL_JOBS_LOGS_DELETE_AFTER_THIS_TIMESPAN;
|
||||
await SweepInternalJobsLogsAsync(ct, dtDeleteCutoff);
|
||||
|
||||
|
||||
//Stealthy check of user count exceeded
|
||||
if (await UserBiz.ActiveCountAsync() > AyaNova.Core.License.ActiveKey.ActiveNumber)
|
||||
{
|
||||
var msg = $"E1020 - Active count exceeded capacity";
|
||||
AyaNova.Util.ServiceProviderProvider.ServerState.SetSystemLock(msg);
|
||||
log.LogCritical(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
lastSweep = DateTime.UtcNow;
|
||||
}
|
||||
@@ -76,7 +85,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
await JobsBiz.RemoveJobAndLogsAsync(j.GId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -114,7 +123,7 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
private static async Task SweepInternalJobsLogsAsync(AyContext ct, DateTime dtDeleteCutoff)
|
||||
{
|
||||
{
|
||||
//Get the deleteable list (this is for reporting, could easily just do it in one go)
|
||||
var logs = await ct.OpsJobLog
|
||||
.AsNoTracking()
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace AyaNova.Generator
|
||||
{
|
||||
if (!ServerGlobalOpsSettingsCache.BOOTING)
|
||||
{
|
||||
log.LogDebug($"GeneratorService running jobs");
|
||||
log.LogTrace($"GeneratorService running jobs");
|
||||
|
||||
//=================================================================
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user