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;
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 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);
}

View File

@@ -67,7 +67,7 @@ namespace AyaNova.Biz
using (AyContext ct = ServiceProviderProvider.DBContext)
{
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.SaveChangesAsync();
}
@@ -227,7 +227,7 @@ namespace AyaNova.Biz
catch (Exception ex)
{
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 UpdateJobStatusAsync(j.GId, JobStatus.Failed);
}
@@ -257,7 +257,7 @@ namespace AyaNova.Biz
catch (Exception ex)
{
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 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
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);
var seedLevel = (Seeder.Level.SeedLevel)jobData["seedLevel"].Value<int>();
var timeZoneOffset = jobData["timeZoneOffset"].Value<decimal>();
var seed = new Util.Seeder();
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);
}

View File

@@ -51,7 +51,7 @@ namespace AyaNova.Biz
//LOCK DOWN SERVER
apiServerState = (AyaNova.Api.ControllerHelpers.ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(AyaNova.Api.ControllerHelpers.ApiServerState));
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);
DateTime dtStartBackup=DateTime.Now;
@@ -63,7 +63,7 @@ namespace AyaNova.Biz
//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
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);
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
if (ServerGlobalOpsSettingsCache.Backup.BackupAttachments)
{
await JobsBiz.LogJobAsync(Guid.Empty, $"Attachments backup starting");
await JobsBiz.LogJobAsync(Guid.Empty, $"LT:Backup LT:Attachments");
FileUtil.BackupAttachments(DemandFileNamePrepend);
var ms = "Backup of file attachments completed OK";
log.LogDebug(ms);
@@ -102,7 +102,7 @@ namespace AyaNova.Biz
}
//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);
//v.next - COPY TO ONLINE STORAGE
@@ -114,7 +114,7 @@ namespace AyaNova.Biz
}
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));
log.LogError(ex, "Backup failed");
await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, "Backup failed","Backup", ex);
@@ -127,7 +127,7 @@ namespace AyaNova.Biz
ServerGlobalOpsSettingsCache.SetNextBackup();
apiServerState.ResumePriorState();
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)
{
//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()}");
await JobsBiz.UpdateJobStatusAsync(j.GId, JobStatus.Failed);
}

View File

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

View File

@@ -1812,6 +1812,7 @@
"BackupFiles": "Backup files",
"BackupNow": "Backup now",
"AreYouSureBackupNow": "Server will be locked during backup. Are you sure?",
"BackupDeleteOld":"Deleting old backup files",
"FileName": "Name",
"FileSize": "Size",
"FileDate": "Date",
@@ -1858,6 +1859,7 @@
"SeedLevelLarge": "Large - multi-region fully staffed",
"SeedLevelHuge": "Huge - very large dataset, will take a few minutes to generate",
"StartJob": "Start job",
"JobCreated": "Server job created",
"JobCompleted": "Job completed",
"JobFailed": "Job failed",
"JobExclusiveWarning": "WARNING: this job will temporarily suspend all user access to the server",
@@ -1964,5 +1966,6 @@
"BatchDeleteJob": "Batch delete job",
"BatchJob": "Batch job",
"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",
"BackupNow": "Iniciar copia de seguridad ahora",
"AreYouSureBackupNow": "El servidor se bloqueará durante la copia de seguridad. ¿Estás seguro?",
"BackupDeleteOld":"Eliminar archivos de respaldo antiguos",
"FileName": "Nombre",
"FileSize": "Tamaño",
"FileDate": "Date",
@@ -1858,6 +1859,7 @@
"SeedLevelLarge": "Grande - multi-región con personal completo",
"SeedLevelHuge": "Enorme conjunto de datos muy grande, tomará unos minutos generar",
"StartJob": "Comenzar trabajo",
"JobCreated": "Trabajo de servidor creado",
"JobCompleted": "Trabajo completo",
"JobFailed": "Trabajo fallido",
"JobExclusiveWarning": "ADVERTENCIA: este trabajo suspenderá temporalmente todo acceso de usuario al servidor",
@@ -1964,5 +1966,6 @@
"BatchDeleteJob": "Trabajo de eliminación por lotes",
"BatchJob": "Trabajo por lotes",
"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",
"BackupNow": "Lancer la sauvegarde maintenant",
"AreYouSureBackupNow": "Le serveur sera verrouillé pendant la sauvegarde. Êtes-vous sûr?",
"BackupDeleteOld":"Suppression des anciens fichiers de sauvegarde",
"FileName": "Nom",
"FileSize": "Taille",
"FileDate": "Date",
@@ -1858,6 +1859,7 @@
"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",
"StartJob": "Commencer le travail",
"JobCreated": "Travail serveur créé",
"JobCompleted": "Travail terminé",
"JobFailed": "Le travail a échoué",
"JobExclusiveWarning": "AVERTISSEMENT: ce travail suspend temporairement tout accès utilisateur au serveur",
@@ -1964,5 +1966,6 @@
"BatchDeleteJob": "Tâche de suppression par lots",
"BatchJob": "Travail par lots",
"Failed": "Échec",
"ProcessingJob": "Traitement du travail du serveur"
"ProcessingJob": "Traitement du travail du serveur",
"TimedOut":"Délai dépassé"
}