This commit is contained in:
2018-10-11 21:37:05 +00:00
parent 5e6a042dcf
commit 9de3924286
5 changed files with 56 additions and 25 deletions

View File

@@ -39,7 +39,7 @@ IMMEDIATE ITEMS:
- Seeder should be changed to log job info for each step - Seeder should be changed to log job info for each step
- Should server show uptime? - Should server show uptime?
- Log route: Add a route to download *all* log files as a single zip archive which will make life much easier for analysis

View File

@@ -92,9 +92,9 @@ https://risingstars.js.org/2017/en/
- Run new image - Run new image
- sudo docker-compose up -d - sudo docker-compose up -d
- Restart NGINX container as it seems to lose it's mind when the AyaNova container is restarted (502 BAD GATEWAY error) - Restart NGINX container (IF NECESSARY) as it seems to sometimes lose it's mind when the AyaNova container is restarted (502 BAD GATEWAY error)
- from /docker/letsencrypt-docker-nginx/src/production run sudo docker-compose up -d - use the restartnginx.sh script in xfer at the server
- Or just use the restartnginx.sh script in xfer at the server - or from /docker/letsencrypt-docker-nginx/src/production run sudo docker-compose up -d
- Test - Test
- If 502 BAD GATEWAY then AyaNova server is not up so the NGINX config bombs because it's proxying to it. - If 502 BAD GATEWAY then AyaNova server is not up so the NGINX config bombs because it's proxying to it.
@@ -107,10 +107,13 @@ https://risingstars.js.org/2017/en/
- Stop container if not already stopped: execute sudo docker-compose down - Stop container if not already stopped: execute sudo docker-compose down
- Edit docker-compose.yml, uncomment line with erase db environment variable and re-start to erase db - Edit docker-compose.yml, uncomment line with erase db environment variable and re-start to erase db
- sudo docker-compose up -d - sudo docker-compose up -d
- Stop the container again, use nano to edit docker-compose.yml and re-comment the erase db evenironment variable - Stop the container again, use nano to edit docker-compose.yml and re-comment the erase db environment variable
- Start the container again with the up command - Start the container again with the up command
- FETCH TEST KEY: - FETCH TEST KEY:
- Go into the api explorer, authenticate then select the POST to license route (not the TRIAL one), this will fetch a test key and install it - Go into the api explorer, authenticate then
- select the POST to license Trial route first { "registeredTo": "TestCo", "emailAddress": "cardjohn@ayanova.com"}
- This seems to setup the db to accept a trial key when fetching the regular key next
- select the POST to license route (not the TRIAL one), this will fetch a test key and install it
- SEED DB: - SEED DB:
- Go to trial route and pick seed level (HUGE for proper testing) and activate - Go to trial route and pick seed level (HUGE for proper testing) and activate
- NOTE: as of today 2018-10-9 it takes 8 minutes at the Devops server to generate the HUGE dataset - NOTE: as of today 2018-10-9 it takes 8 minutes at the Devops server to generate the HUGE dataset

View File

@@ -228,6 +228,16 @@ namespace AyaNova.Biz
/// <summary>
/// Make a log entry for a job
/// (no context version)
/// </summary>
/// <param name="jobId"></param>
/// <param name="statusText"></param>
internal static OpsJobLog LogJob(Guid jobId, string statusText)
{
return LogJob(jobId, statusText);
}
/// <summary> /// <summary>
/// Make a log entry for a job /// Make a log entry for a job
@@ -235,8 +245,10 @@ namespace AyaNova.Biz
/// <param name="jobId"></param> /// <param name="jobId"></param>
/// <param name="statusText"></param> /// <param name="statusText"></param>
/// <param name="ct"></param> /// <param name="ct"></param>
internal static OpsJobLog LogJob(Guid jobId, string statusText, AyContext ct) internal static OpsJobLog LogJob(Guid jobId, string statusText, AyContext ct = null)
{ {
if (ct == null)
ct = ServiceProviderProvider.DBContext;
if (string.IsNullOrWhiteSpace(statusText)) if (string.IsNullOrWhiteSpace(statusText))
statusText = "No status provided"; statusText = "No status provided";
OpsJobLog newObj = new OpsJobLog(); OpsJobLog newObj = new OpsJobLog();

View File

@@ -70,7 +70,7 @@ namespace AyaNova.Biz
//Get the import filename from the jsondata //Get the import filename from the jsondata
JObject jobData = JObject.Parse(job.JobInfo); JObject jobData = JObject.Parse(job.JobInfo);
var seedLevel = (Seeder.SeedLevel)jobData["seedLevel"].Value<int>(); var seedLevel = (Seeder.SeedLevel)jobData["seedLevel"].Value<int>();
Seeder.SeedDatabase(seedLevel); Seeder.SeedDatabase(seedLevel, job.GId);
JobsBiz.LogJob(job.GId, "Finished.", ct); JobsBiz.LogJob(job.GId, "Finished.", ct);
JobsBiz.UpdateJobStatus(job.GId, JobStatus.Completed, ct); JobsBiz.UpdateJobStatus(job.GId, JobStatus.Completed, ct);
await Task.CompletedTask; await Task.CompletedTask;

View File

@@ -14,15 +14,22 @@ namespace AyaNova.Util
public static class Seeder public static class Seeder
{ {
public enum SeedLevel { SmallOneManShopTrialDataSet, MediumLocalServiceCompanyTrialDataSet, LargeCorporateMultiRegionalTrialDataSet, HugeForLoadTest }; public enum SeedLevel { SmallOneManShopTrialDataSet, MediumLocalServiceCompanyTrialDataSet, LargeCorporateMultiRegionalTrialDataSet, HugeForLoadTest };
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
//Seed database for trial and testing purposes //Seed database for trial and testing purposes
// //
public static void SeedDatabase(SeedLevel slevel) public static void SeedDatabase(SeedLevel slevel)
{ {
SeedDatabase(slevel, Guid.Empty);
}
public static void SeedDatabase(SeedLevel slevel, Guid JobId)
{
bool LogJob = JobId != Guid.Empty;
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("Seeder"); ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("Seeder");
ApiServerState apiServerState = (ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(ApiServerState)); ApiServerState apiServerState = (ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(ApiServerState));
@@ -36,15 +43,16 @@ namespace AyaNova.Util
try try
{ {
log.LogInformation("SEEDER: Seed data level - " + slevel.ToString()); LogStatus(JobId, LogJob, log, $"SEEDER: Seed data level - {slevel.ToString()}");
//Only allow this in a trial database //Only allow this in a trial database
if (!AyaNova.Core.License.ActiveKey.TrialLicense) if (!AyaNova.Core.License.ActiveKey.TrialLicense)
{ {
throw new System.NotSupportedException("This database has a registered license key and can't be seeded."); var msg = "This database has a registered license key so it can't be seeded";
LogStatus(JobId, LogJob, log, msg);
throw new System.NotSupportedException(msg);
} }
log.LogInformation("Setting server state to OpsOnly");
apiServerState.SetOpsOnly("Seeding database"); apiServerState.SetOpsOnly("Seeding database");
//Erase all the data except for the license, schema and the manager user //Erase all the data except for the license, schema and the manager user
@@ -124,7 +132,7 @@ namespace AyaNova.Util
//Each location has a full staff and corporate head office has an overarching staff member in charge of each location //Each location has a full staff and corporate head office has an overarching staff member in charge of each location
//PERF //PERF
log.LogInformation($"Seeding 279 user(s)...."); LogStatus(JobId, LogJob, log, $"Seeding 279 user(s)....");
var watch = new Stopwatch(); var watch = new Stopwatch();
watch.Start(); watch.Start();
@@ -172,18 +180,17 @@ namespace AyaNova.Util
//PERF //PERF
watch.Stop(); watch.Stop();
log.LogInformation($"279 Users seeded in {watch.ElapsedMilliseconds} ms"); LogStatus(JobId, LogJob, log, $"279 Users seeded in {watch.ElapsedMilliseconds} ms");
//5000 widgets //5000 widgets
log.LogInformation($"Seeding 5000 Widgets...."); LogStatus(JobId, LogJob, log, $"Seeding 5,000 Widgets....");
watch = new Stopwatch(); watch = new Stopwatch();
watch.Start(); watch.Start();
GenSeedWidget(log, 5000); GenSeedWidget(log, 5000);
//PERF //PERF
watch.Stop(); watch.Stop();
log.LogInformation($"5k Widgets seeded in {watch.ElapsedMilliseconds} ms"); LogStatus(JobId, LogJob, log, $"5k Widgets seeded in {watch.ElapsedMilliseconds} ms");
#endregion genlarge #endregion genlarge
} }
break; break;
@@ -195,7 +202,7 @@ namespace AyaNova.Util
//It is acceptable for this seeding to take many hours as it would normally be used rarely //It is acceptable for this seeding to take many hours as it would normally be used rarely
//PERF //PERF
log.LogInformation($"Seeding 1,410 user(s)...."); LogStatus(JobId, LogJob, log, $"Seeding 1,410 user(s)....");
var watch = new Stopwatch(); var watch = new Stopwatch();
watch.Start(); watch.Start();
@@ -243,27 +250,27 @@ namespace AyaNova.Util
//PERF //PERF
watch.Stop(); watch.Stop();
log.LogInformation($"1,410 Users seeded in {watch.ElapsedMilliseconds} ms"); LogStatus(JobId, LogJob, log, $"1,410 Users seeded in {watch.ElapsedMilliseconds} ms");
//20000 widgets //20000 widgets
log.LogInformation($"Seeding 20,000 Widgets...."); LogStatus(JobId, LogJob, log, $"Seeding 20,000 Widgets....");
watch = new Stopwatch(); watch = new Stopwatch();
watch.Start(); watch.Start();
GenSeedWidget(log, 20000); GenSeedWidget(log, 20000);
watch.Stop(); watch.Stop();
log.LogInformation($"20k Widgets seeded in {watch.ElapsedMilliseconds} ms"); LogStatus(JobId, LogJob, log, $"20k Widgets seeded in {watch.ElapsedMilliseconds} ms");
#endregion genhuge #endregion genhuge
} }
break; break;
} }
LogStatus(JobId, LogJob, log, "Seeding completed successfully");
log.LogInformation("Seeding completed successfully");
} }
catch (Exception ex) catch (Exception ex)
{ {
log.LogError(ex, "Seeder:SeedDatabase error during ops"); log.LogError(ex, "Seeder:SeedDatabase error during ops");
if (LogJob)
JobsBiz.LogJob(JobId, $"Seeder:SeedDatabase error during ops\r\n{ex.Message}");
throw ex; throw ex;
} }
finally finally
@@ -274,6 +281,15 @@ namespace AyaNova.Util
} }
//Log the status and also job if it's run via job
private static void LogStatus(Guid JobId, bool LogJob, ILogger log, string msg)
{
log.LogInformation(msg);
if (LogJob)
JobsBiz.LogJob(JobId, msg);
}
public static long RUNNING_COUNT = 0; public static long RUNNING_COUNT = 0;
public static string Uniquify(string s) public static string Uniquify(string s)
{ {