This commit is contained in:
2020-12-10 20:23:27 +00:00
parent 0e2cf7a0c7
commit cd40e477bd
9 changed files with 30 additions and 18 deletions

View File

@@ -128,9 +128,9 @@ namespace AyaNova.Biz
{ {
var sleepTime = 30 * 1000; var sleepTime = 30 * 1000;
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Running); await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Running);
await JobsBiz.LogJobAsync(job.GId, $"Test job started, sleeping for {sleepTime / 1000} seconds..."); await JobsBiz.LogJobAsync(job.GId, $"LT:JobStart");
await Task.Delay(sleepTime); await Task.Delay(sleepTime);
await JobsBiz.LogJobAsync(job.GId, "Test job done sleeping setting status to finished"); await JobsBiz.LogJobAsync(job.GId, "LT:JobCompleted");
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed); await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed);
} }

View File

@@ -67,7 +67,7 @@ namespace AyaNova.Biz
using (AyContext ct = ServiceProviderProvider.DBContext) using (AyContext ct = ServiceProviderProvider.DBContext)
{ {
log.LogDebug($"Adding new job:{newJob.ToString()}"); log.LogDebug($"Adding new job:{newJob.ToString()}");
await LogJobAsync(newJob.GId, $"Adding new job \"{newJob.Name}\" to queue"); await LogJobAsync(newJob.GId, $"LT:JobCreated \"{newJob.Name}\"");
await ct.OpsJob.AddAsync(newJob); await ct.OpsJob.AddAsync(newJob);
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
} }
@@ -227,7 +227,7 @@ namespace AyaNova.Biz
catch (Exception ex) catch (Exception ex)
{ {
log.LogError(ex, $"ProcessJobs::Exclusive -> job {j.Name} failed with exception"); log.LogError(ex, $"ProcessJobs::Exclusive -> job {j.Name} failed with exception");
await LogJobAsync(j.GId, "Job failed with errors:"); await LogJobAsync(j.GId, "LT:JobFailed");
await LogJobAsync(j.GId, ExceptionUtil.ExtractAllExceptionMessages(ex)); await LogJobAsync(j.GId, ExceptionUtil.ExtractAllExceptionMessages(ex));
await UpdateJobStatusAsync(j.GId, JobStatus.Failed); await UpdateJobStatusAsync(j.GId, JobStatus.Failed);
} }
@@ -257,7 +257,7 @@ namespace AyaNova.Biz
catch (Exception ex) catch (Exception ex)
{ {
log.LogError(ex, $"ProcessJobs::Shared -> job {j.Name} failed with exception"); log.LogError(ex, $"ProcessJobs::Shared -> job {j.Name} failed with exception");
await LogJobAsync(j.GId, "Job failed with errors:"); await LogJobAsync(j.GId, "LT:JobFailed");
await LogJobAsync(j.GId, ExceptionUtil.ExtractAllExceptionMessages(ex)); await LogJobAsync(j.GId, ExceptionUtil.ExtractAllExceptionMessages(ex));
await UpdateJobStatusAsync(j.GId, JobStatus.Failed); await UpdateJobStatusAsync(j.GId, JobStatus.Failed);
} }

View File

@@ -61,13 +61,13 @@ namespace AyaNova.Biz
//basically any error condition during job processing should throw up an exception if it can't be handled //basically any error condition during job processing should throw up an exception if it can't be handled
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Running); await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Running);
await JobsBiz.LogJobAsync(job.GId, $"Starting..."); await JobsBiz.LogJobAsync(job.GId, $"LT:StartJob");
JObject jobData = JObject.Parse(job.JobInfo); JObject jobData = JObject.Parse(job.JobInfo);
var seedLevel = (Seeder.Level.SeedLevel)jobData["seedLevel"].Value<int>(); var seedLevel = (Seeder.Level.SeedLevel)jobData["seedLevel"].Value<int>();
var timeZoneOffset = jobData["timeZoneOffset"].Value<decimal>(); var timeZoneOffset = jobData["timeZoneOffset"].Value<decimal>();
var seed = new Util.Seeder(); var seed = new Util.Seeder();
await seed.SeedDatabaseAsync(seedLevel, job.GId, timeZoneOffset); await seed.SeedDatabaseAsync(seedLevel, job.GId, timeZoneOffset);
await JobsBiz.LogJobAsync(job.GId, "Finished."); await JobsBiz.LogJobAsync(job.GId, "LT:JobCompleted");
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed); await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed);
} }

View File

@@ -51,7 +51,7 @@ namespace AyaNova.Biz
//LOCK DOWN SERVER //LOCK DOWN SERVER
apiServerState = (AyaNova.Api.ControllerHelpers.ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(AyaNova.Api.ControllerHelpers.ApiServerState)); apiServerState = (AyaNova.Api.ControllerHelpers.ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(AyaNova.Api.ControllerHelpers.ApiServerState));
apiServerState.SetClosed("BACKUP RUNNING"); apiServerState.SetClosed("BACKUP RUNNING");
var jobstartmessage = $"Starting backup job {(OnDemand ? "manual / on demand" : "scheduled") } "; var jobstartmessage = $"LT:Backup LT:StartJob {(OnDemand ? "manual / on demand" : "scheduled") } ";
await JobsBiz.LogJobAsync(Guid.Empty, jobstartmessage); await JobsBiz.LogJobAsync(Guid.Empty, jobstartmessage);
DateTime dtStartBackup=DateTime.Now; DateTime dtStartBackup=DateTime.Now;
@@ -63,7 +63,7 @@ namespace AyaNova.Biz
//this is valid on windows //this is valid on windows
//C:\data\code\PostgreSQLPortable_12.0\App\PgSQL\bin\pg_dump --dbname=postgresql://postgres:raven@127.0.0.1:5432/AyaNova -Fc > huge_new.backup //C:\data\code\PostgreSQLPortable_12.0\App\PgSQL\bin\pg_dump --dbname=postgresql://postgres:raven@127.0.0.1:5432/AyaNova -Fc > huge_new.backup
await JobsBiz.LogJobAsync(Guid.Empty, $"Data backup starting"); // await JobsBiz.LogJobAsync(Guid.Empty, $"Data backup starting");
Npgsql.NpgsqlConnectionStringBuilder PostgresConnectionString = new Npgsql.NpgsqlConnectionStringBuilder(ServerBootConfig.AYANOVA_DB_CONNECTION); Npgsql.NpgsqlConnectionStringBuilder PostgresConnectionString = new Npgsql.NpgsqlConnectionStringBuilder(ServerBootConfig.AYANOVA_DB_CONNECTION);
var DBNameParameter = $"--dbname=postgresql://{PostgresConnectionString.Username}:{PostgresConnectionString.Password}@{PostgresConnectionString.Host}:{PostgresConnectionString.Port}/{PostgresConnectionString.Database}"; var DBNameParameter = $"--dbname=postgresql://{PostgresConnectionString.Username}:{PostgresConnectionString.Password}@{PostgresConnectionString.Host}:{PostgresConnectionString.Port}/{PostgresConnectionString.Database}";
@@ -94,7 +94,7 @@ namespace AyaNova.Biz
//DO FILE BACKUP IF ATTACHMENTS BACKED UP //DO FILE BACKUP IF ATTACHMENTS BACKED UP
if (ServerGlobalOpsSettingsCache.Backup.BackupAttachments) if (ServerGlobalOpsSettingsCache.Backup.BackupAttachments)
{ {
await JobsBiz.LogJobAsync(Guid.Empty, $"Attachments backup starting"); await JobsBiz.LogJobAsync(Guid.Empty, $"LT:Backup LT:Attachments");
FileUtil.BackupAttachments(DemandFileNamePrepend); FileUtil.BackupAttachments(DemandFileNamePrepend);
var ms = "Backup of file attachments completed OK"; var ms = "Backup of file attachments completed OK";
log.LogDebug(ms); log.LogDebug(ms);
@@ -102,7 +102,7 @@ namespace AyaNova.Biz
} }
//PRUNE DATA BACKUP SETS NOT KEPT //PRUNE DATA BACKUP SETS NOT KEPT
await JobsBiz.LogJobAsync(Guid.Empty, $"Pruning old backup sets"); await JobsBiz.LogJobAsync(Guid.Empty, $"LT:BackupDeleteOld");
FileUtil.DatabaseBackupCleanUp(ServerGlobalOpsSettingsCache.Backup.BackupSetsToKeep); FileUtil.DatabaseBackupCleanUp(ServerGlobalOpsSettingsCache.Backup.BackupSetsToKeep);
//v.next - COPY TO ONLINE STORAGE //v.next - COPY TO ONLINE STORAGE
@@ -114,7 +114,7 @@ namespace AyaNova.Biz
} }
catch (Exception ex) catch (Exception ex)
{ {
await JobsBiz.LogJobAsync(Guid.Empty, "Backup failed with errors:"); await JobsBiz.LogJobAsync(Guid.Empty, "LT:JobFailed");
await JobsBiz.LogJobAsync(Guid.Empty, ExceptionUtil.ExtractAllExceptionMessages(ex)); await JobsBiz.LogJobAsync(Guid.Empty, ExceptionUtil.ExtractAllExceptionMessages(ex));
log.LogError(ex, "Backup failed"); log.LogError(ex, "Backup failed");
await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, "Backup failed","Backup", ex); await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, "Backup failed","Backup", ex);
@@ -127,7 +127,7 @@ namespace AyaNova.Biz
ServerGlobalOpsSettingsCache.SetNextBackup(); ServerGlobalOpsSettingsCache.SetNextBackup();
apiServerState.ResumePriorState(); apiServerState.ResumePriorState();
BackupIsRunning = false; BackupIsRunning = false;
await JobsBiz.LogJobAsync(Guid.Empty, $"Backup - fully complete, server re-opened"); await JobsBiz.LogJobAsync(Guid.Empty, "LT:JobCompleted");
} }
} }

View File

@@ -115,7 +115,7 @@ namespace AyaNova.Biz
foreach (OpsJob j in jobs) foreach (OpsJob j in jobs)
{ {
//OPSMETRIC //OPSMETRIC
await JobsBiz.LogJobAsync(j.GId, "Job took too long to run - setting to failed"); await JobsBiz.LogJobAsync(j.GId, "LT:JobFailed LT:TimedOut");
log.LogError($"Job found job stuck in running status and set to failed: deadline={dtRunningDeadline.ToString()}, jobId={j.GId.ToString()}, jobname={j.Name}, jobtype={j.JobType.ToString()}, jobObjectType={j.ObjectType.ToString()}, jobObjectId={j.ObjectId.ToString()}"); log.LogError($"Job found job stuck in running status and set to failed: deadline={dtRunningDeadline.ToString()}, jobId={j.GId.ToString()}, jobname={j.Name}, jobtype={j.JobType.ToString()}, jobObjectType={j.ObjectType.ToString()}, jobObjectId={j.ObjectId.ToString()}");
await JobsBiz.UpdateJobStatusAsync(j.GId, JobStatus.Failed); await JobsBiz.UpdateJobStatusAsync(j.GId, JobStatus.Failed);
} }

View File

@@ -1812,6 +1812,7 @@
"BackupFiles": "Liste der Sicherungsdateien", "BackupFiles": "Liste der Sicherungsdateien",
"BackupNow": "Starten Sie jetzt das Backup", "BackupNow": "Starten Sie jetzt das Backup",
"AreYouSureBackupNow": "Der Server wird während der Sicherung gesperrt. Bist du sicher?", "AreYouSureBackupNow": "Der Server wird während der Sicherung gesperrt. Bist du sicher?",
"BackupDeleteOld":"Alte Sicherungsdateien löschen",
"FileName": "Name", "FileName": "Name",
"FileSize": "Größe", "FileSize": "Größe",
"FileDate": "Datum", "FileDate": "Datum",
@@ -1858,6 +1859,7 @@
"SeedLevelLarge": "Groß - Multi-Region voll besetzt", "SeedLevelLarge": "Groß - Multi-Region voll besetzt",
"SeedLevelHuge": "Riesig - sehr großer Datensatz, die Generierung dauert einige Minuten", "SeedLevelHuge": "Riesig - sehr großer Datensatz, die Generierung dauert einige Minuten",
"StartJob": "Job starten", "StartJob": "Job starten",
"JobCreated": "Serverjob erstellt",
"JobCompleted": "Arbeit erledigt", "JobCompleted": "Arbeit erledigt",
"JobFailed": "Job fehlgeschlagen", "JobFailed": "Job fehlgeschlagen",
"JobExclusiveWarning": "WARNUNG: Dieser Job unterbricht vorübergehend den gesamten Benutzerzugriff auf den Server", "JobExclusiveWarning": "WARNUNG: Dieser Job unterbricht vorübergehend den gesamten Benutzerzugriff auf den Server",
@@ -1964,5 +1966,6 @@
"BatchDeleteJob": "Batch-Löschauftrag", "BatchDeleteJob": "Batch-Löschauftrag",
"BatchJob": "Batch-Job", "BatchJob": "Batch-Job",
"Failed": "Fehlgeschlagen", "Failed": "Fehlgeschlagen",
"ProcessingJob": "Serverjob verarbeiten" "ProcessingJob": "Serverjob verarbeiten",
"TimedOut":"Zeitüberschreitung"
} }

View File

@@ -1812,6 +1812,7 @@
"BackupFiles": "Backup files", "BackupFiles": "Backup files",
"BackupNow": "Backup now", "BackupNow": "Backup now",
"AreYouSureBackupNow": "Server will be locked during backup. Are you sure?", "AreYouSureBackupNow": "Server will be locked during backup. Are you sure?",
"BackupDeleteOld":"Deleting old backup files",
"FileName": "Name", "FileName": "Name",
"FileSize": "Size", "FileSize": "Size",
"FileDate": "Date", "FileDate": "Date",
@@ -1858,6 +1859,7 @@
"SeedLevelLarge": "Large - multi-region fully staffed", "SeedLevelLarge": "Large - multi-region fully staffed",
"SeedLevelHuge": "Huge - very large dataset, will take a few minutes to generate", "SeedLevelHuge": "Huge - very large dataset, will take a few minutes to generate",
"StartJob": "Start job", "StartJob": "Start job",
"JobCreated": "Server job created",
"JobCompleted": "Job completed", "JobCompleted": "Job completed",
"JobFailed": "Job failed", "JobFailed": "Job failed",
"JobExclusiveWarning": "WARNING: this job will temporarily suspend all user access to the server", "JobExclusiveWarning": "WARNING: this job will temporarily suspend all user access to the server",
@@ -1964,5 +1966,6 @@
"BatchDeleteJob": "Batch delete job", "BatchDeleteJob": "Batch delete job",
"BatchJob": "Batch job", "BatchJob": "Batch job",
"Failed": "Failed", "Failed": "Failed",
"ProcessingJob": "Processing server job" "ProcessingJob": "Processing server job",
"TimedOut":"Timed out"
} }

View File

@@ -1812,6 +1812,7 @@
"BackupFiles": "Lista de archivos de respaldo", "BackupFiles": "Lista de archivos de respaldo",
"BackupNow": "Iniciar copia de seguridad ahora", "BackupNow": "Iniciar copia de seguridad ahora",
"AreYouSureBackupNow": "El servidor se bloqueará durante la copia de seguridad. ¿Estás seguro?", "AreYouSureBackupNow": "El servidor se bloqueará durante la copia de seguridad. ¿Estás seguro?",
"BackupDeleteOld":"Eliminar archivos de respaldo antiguos",
"FileName": "Nombre", "FileName": "Nombre",
"FileSize": "Tamaño", "FileSize": "Tamaño",
"FileDate": "Date", "FileDate": "Date",
@@ -1858,6 +1859,7 @@
"SeedLevelLarge": "Grande - multi-región con personal completo", "SeedLevelLarge": "Grande - multi-región con personal completo",
"SeedLevelHuge": "Enorme conjunto de datos muy grande, tomará unos minutos generar", "SeedLevelHuge": "Enorme conjunto de datos muy grande, tomará unos minutos generar",
"StartJob": "Comenzar trabajo", "StartJob": "Comenzar trabajo",
"JobCreated": "Trabajo de servidor creado",
"JobCompleted": "Trabajo completo", "JobCompleted": "Trabajo completo",
"JobFailed": "Trabajo fallido", "JobFailed": "Trabajo fallido",
"JobExclusiveWarning": "ADVERTENCIA: este trabajo suspenderá temporalmente todo acceso de usuario al servidor", "JobExclusiveWarning": "ADVERTENCIA: este trabajo suspenderá temporalmente todo acceso de usuario al servidor",
@@ -1964,5 +1966,6 @@
"BatchDeleteJob": "Trabajo de eliminación por lotes", "BatchDeleteJob": "Trabajo de eliminación por lotes",
"BatchJob": "Trabajo por lotes", "BatchJob": "Trabajo por lotes",
"Failed": "Fallido", "Failed": "Fallido",
"ProcessingJob": "Procesando trabajo del servidor" "ProcessingJob": "Procesando trabajo del servidor",
"TimedOut":"Tiempo de espera agotado"
} }

View File

@@ -1812,6 +1812,7 @@
"BackupFiles": "Liste des fichiers de sauvegarde", "BackupFiles": "Liste des fichiers de sauvegarde",
"BackupNow": "Lancer la sauvegarde maintenant", "BackupNow": "Lancer la sauvegarde maintenant",
"AreYouSureBackupNow": "Le serveur sera verrouillé pendant la sauvegarde. Êtes-vous sûr?", "AreYouSureBackupNow": "Le serveur sera verrouillé pendant la sauvegarde. Êtes-vous sûr?",
"BackupDeleteOld":"Suppression des anciens fichiers de sauvegarde",
"FileName": "Nom", "FileName": "Nom",
"FileSize": "Taille", "FileSize": "Taille",
"FileDate": "Date", "FileDate": "Date",
@@ -1858,6 +1859,7 @@
"SeedLevelLarge": "Grand - multi-région entièrement doté en personnel", "SeedLevelLarge": "Grand - multi-région entièrement doté en personnel",
"SeedLevelHuge": "Énorme - très grand ensemble de données, il faudra quelques minutes pour générer", "SeedLevelHuge": "Énorme - très grand ensemble de données, il faudra quelques minutes pour générer",
"StartJob": "Commencer le travail", "StartJob": "Commencer le travail",
"JobCreated": "Travail serveur créé",
"JobCompleted": "Travail terminé", "JobCompleted": "Travail terminé",
"JobFailed": "Le travail a échoué", "JobFailed": "Le travail a échoué",
"JobExclusiveWarning": "AVERTISSEMENT: ce travail suspend temporairement tout accès utilisateur au serveur", "JobExclusiveWarning": "AVERTISSEMENT: ce travail suspend temporairement tout accès utilisateur au serveur",
@@ -1964,5 +1966,6 @@
"BatchDeleteJob": "Tâche de suppression par lots", "BatchDeleteJob": "Tâche de suppression par lots",
"BatchJob": "Travail par lots", "BatchJob": "Travail par lots",
"Failed": "Échec", "Failed": "Échec",
"ProcessingJob": "Traitement du travail du serveur" "ProcessingJob": "Traitement du travail du serveur",
"TimedOut":"Délai dépassé"
} }