This commit is contained in:
@@ -7,6 +7,9 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Util;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Biz;
|
||||
using AyaNova.Util;
|
||||
|
||||
|
||||
namespace AyaNova.Biz
|
||||
@@ -155,9 +158,36 @@ namespace AyaNova.Biz
|
||||
ActivelyProcessing = true;
|
||||
try
|
||||
{
|
||||
//## Critical internal jobs
|
||||
await CoreJobSweeper.DoSweepAsync();
|
||||
//### Critical internal jobs, these run even if there is a license related serverlock
|
||||
//LICENSE FETCH
|
||||
await CoreJobLicense.DoWorkAsync();
|
||||
//"SHENANIGAN" CHECK
|
||||
if (await UserBiz.ActiveCountAsync() > AyaNova.Core.License.ActiveKey.ActiveNumber)
|
||||
{
|
||||
var msg = $"E1020 - Active count exceeded capacity";
|
||||
ServiceProviderProvider.ServerState.SetSystemLock(msg);
|
||||
log.LogCritical(msg);
|
||||
return;
|
||||
}
|
||||
//METRICS
|
||||
CoreJobMetricsSnapshot.DoWork();
|
||||
|
||||
//### Server state dependent jobs
|
||||
ApiServerState serverState = ServiceProviderProvider.ServerState;
|
||||
|
||||
//system lock (no license) is a complete deal breaker for continuation beyond here
|
||||
if (serverState.IsSystemLocked) return;
|
||||
|
||||
//TODO: NOTIFICATIONS
|
||||
//await CoreJobNotify.DoWorkAsync();
|
||||
|
||||
//BACKUP
|
||||
await CoreJobBackup.DoWorkAsync();
|
||||
//JOB SWEEPER
|
||||
await CoreJobSweeper.DoWorkAsync();
|
||||
|
||||
//### API Open only jobs
|
||||
if (!serverState.IsOpen) return;
|
||||
|
||||
//BIZOBJECT DYNAMIC JOBS
|
||||
//get a list of exclusive jobs that are due to happen
|
||||
@@ -167,10 +197,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
try
|
||||
{
|
||||
//System.Diagnostics.Debug.WriteLine($"JobsBiz processing exclusive biz job {j.Name}");
|
||||
await ProcessJobAsync(j);
|
||||
//Capture metrics
|
||||
CoreJobMetricsSnapshot.DoJob();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -181,26 +208,6 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
//System.Diagnostics.Debug.WriteLine($"JobsBiz processing exclusive license check");
|
||||
//License check
|
||||
long CurrentActiveCount = await UserBiz.ActiveCountAsync();
|
||||
long LicensedUserCount = AyaNova.Core.License.ActiveKey.ActiveNumber;
|
||||
// log.LogInformation("JobsBiz::Checking license active count");
|
||||
if (CurrentActiveCount > LicensedUserCount)
|
||||
{
|
||||
var msg = $"E1020 - Active count exceeded capacity";
|
||||
ServiceProviderProvider.ServerState.SetSystemLock(msg);
|
||||
log.LogCritical(msg);
|
||||
return;
|
||||
}
|
||||
//backup
|
||||
//System.Diagnostics.Debug.WriteLine($"JobsBiz processing backup");
|
||||
await CoreJobBackup.DoWorkAsync();//sb exclusive
|
||||
//System.Diagnostics.Debug.WriteLine($"JobsBiz processing metrics snapshotter");
|
||||
|
||||
//Capture metrics
|
||||
CoreJobMetricsSnapshot.DoJob();
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
//NON-EXCLUSIVE JOBS
|
||||
@@ -223,14 +230,6 @@ namespace AyaNova.Biz
|
||||
await UpdateJobStatusAsync(j.GId, JobStatus.Failed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Capture metrics
|
||||
CoreJobMetricsSnapshot.DoJob();
|
||||
|
||||
|
||||
//TODO: NOTIFICATIONS
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user