This commit is contained in:
@@ -2,9 +2,7 @@ using System.Threading;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Biz;
|
||||
using AyaNova.Util;
|
||||
|
||||
namespace AyaNova.Generator
|
||||
{
|
||||
@@ -48,49 +46,32 @@ namespace AyaNova.Generator
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
if (!justStarted)
|
||||
if (!justStarted)//give it a pause to settle on boot
|
||||
{
|
||||
log.LogDebug($"GeneratorService task doing background work.");
|
||||
ApiServerState serverState = ServiceProviderProvider.ServerState;
|
||||
log.LogDebug($"GeneratorService running jobs");
|
||||
|
||||
//=================================================================
|
||||
try
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
{
|
||||
log.LogDebug($"GeneratorService: ServerState is closed returning without processing jobs, will try again next iteration");
|
||||
}
|
||||
else
|
||||
{
|
||||
//System.Diagnostics.Debug.WriteLine($"### GENERATE calling JobsBiz.ProcessJobs");
|
||||
//Capture metrics
|
||||
CoreJobMetricsSnapshot.DoJob();
|
||||
await JobsBiz.ProcessJobsAsync();
|
||||
//Capture metrics again, (calling repeatedly won't increase metrics but will ensure it doesn't miss frequency of capturing)
|
||||
CoreJobMetricsSnapshot.DoJob();
|
||||
//System.Diagnostics.Debug.WriteLine($"### GENERATE BACK FROM calling JobsBiz.ProcessJobs");
|
||||
}
|
||||
await JobsBiz.ProcessJobsAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.LogError(ex, "Generate::ProcessJobs result in exception error ");
|
||||
}
|
||||
//=================================================================
|
||||
|
||||
}
|
||||
await Task.Delay((GENERATE_SECONDS * 1000), stoppingToken);
|
||||
justStarted = false;
|
||||
}
|
||||
|
||||
log.LogDebug($"GeneratorService background task is stopping.");
|
||||
|
||||
log.LogDebug($"GeneratorService is stopping");
|
||||
}
|
||||
|
||||
public override Task StopAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
log.LogDebug($"GeneratorService StopAsync triggered.");
|
||||
log.LogDebug($"GeneratorService StopAsync triggered");
|
||||
return Task.FromResult(0);
|
||||
// Run your graceful clean-up actions
|
||||
// Run any needed clean-up actions
|
||||
}
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
Reference in New Issue
Block a user