This commit is contained in:
@@ -39,7 +39,7 @@ IMMEDIATE ITEMS:
|
||||
- Seeder should be changed to log job info for each step
|
||||
- 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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -92,9 +92,9 @@ https://risingstars.js.org/2017/en/
|
||||
- Run new image
|
||||
- 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)
|
||||
- from /docker/letsencrypt-docker-nginx/src/production run sudo docker-compose up -d
|
||||
- Or just use the restartnginx.sh script in xfer at the server
|
||||
- Restart NGINX container (IF NECESSARY) as it seems to sometimes lose it's mind when the AyaNova container is restarted (502 BAD GATEWAY error)
|
||||
- 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
|
||||
- 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
|
||||
- Edit docker-compose.yml, uncomment line with erase db environment variable and re-start to erase db
|
||||
- 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
|
||||
- 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:
|
||||
- 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
|
||||
|
||||
@@ -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>
|
||||
/// Make a log entry for a job
|
||||
@@ -235,8 +245,10 @@ namespace AyaNova.Biz
|
||||
/// <param name="jobId"></param>
|
||||
/// <param name="statusText"></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))
|
||||
statusText = "No status provided";
|
||||
OpsJobLog newObj = new OpsJobLog();
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace AyaNova.Biz
|
||||
//Get the import filename from the jsondata
|
||||
JObject jobData = JObject.Parse(job.JobInfo);
|
||||
var seedLevel = (Seeder.SeedLevel)jobData["seedLevel"].Value<int>();
|
||||
Seeder.SeedDatabase(seedLevel);
|
||||
Seeder.SeedDatabase(seedLevel, job.GId);
|
||||
JobsBiz.LogJob(job.GId, "Finished.", ct);
|
||||
JobsBiz.UpdateJobStatus(job.GId, JobStatus.Completed, ct);
|
||||
await Task.CompletedTask;
|
||||
|
||||
@@ -14,15 +14,22 @@ namespace AyaNova.Util
|
||||
|
||||
public static class Seeder
|
||||
{
|
||||
|
||||
public enum SeedLevel { SmallOneManShopTrialDataSet, MediumLocalServiceCompanyTrialDataSet, LargeCorporateMultiRegionalTrialDataSet, HugeForLoadTest };
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
//Seed database for trial and testing purposes
|
||||
//
|
||||
|
||||
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");
|
||||
ApiServerState apiServerState = (ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(ApiServerState));
|
||||
|
||||
@@ -36,15 +43,16 @@ namespace AyaNova.Util
|
||||
|
||||
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
|
||||
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");
|
||||
|
||||
//Erase all the data except for the license, schema and the manager user
|
||||
@@ -123,8 +131,8 @@ namespace AyaNova.Util
|
||||
//this is a large corporation with multiple branches in multiple locations all in the same country
|
||||
//Each location has a full staff and corporate head office has an overarching staff member in charge of each location
|
||||
|
||||
//PERF
|
||||
log.LogInformation($"Seeding 279 user(s)....");
|
||||
//PERF
|
||||
LogStatus(JobId, LogJob, log, $"Seeding 279 user(s)....");
|
||||
var watch = new Stopwatch();
|
||||
watch.Start();
|
||||
|
||||
@@ -172,18 +180,17 @@ namespace AyaNova.Util
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
log.LogInformation($"279 Users seeded in {watch.ElapsedMilliseconds} ms");
|
||||
|
||||
LogStatus(JobId, LogJob, log, $"279 Users seeded in {watch.ElapsedMilliseconds} ms");
|
||||
|
||||
//5000 widgets
|
||||
log.LogInformation($"Seeding 5000 Widgets....");
|
||||
LogStatus(JobId, LogJob, log, $"Seeding 5,000 Widgets....");
|
||||
watch = new Stopwatch();
|
||||
watch.Start();
|
||||
GenSeedWidget(log, 5000);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
log.LogInformation($"5k Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
||||
LogStatus(JobId, LogJob, log, $"5k Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
||||
#endregion genlarge
|
||||
}
|
||||
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
|
||||
|
||||
//PERF
|
||||
log.LogInformation($"Seeding 1,410 user(s)....");
|
||||
LogStatus(JobId, LogJob, log, $"Seeding 1,410 user(s)....");
|
||||
var watch = new Stopwatch();
|
||||
watch.Start();
|
||||
|
||||
@@ -243,27 +250,27 @@ namespace AyaNova.Util
|
||||
|
||||
//PERF
|
||||
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
|
||||
log.LogInformation($"Seeding 20,000 Widgets....");
|
||||
LogStatus(JobId, LogJob, log, $"Seeding 20,000 Widgets....");
|
||||
watch = new Stopwatch();
|
||||
watch.Start();
|
||||
GenSeedWidget(log, 20000);
|
||||
watch.Stop();
|
||||
log.LogInformation($"20k Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
||||
LogStatus(JobId, LogJob, log, $"20k Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
||||
#endregion genhuge
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
log.LogInformation("Seeding completed successfully");
|
||||
LogStatus(JobId, LogJob, log, "Seeding completed successfully");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.LogError(ex, "Seeder:SeedDatabase error during ops");
|
||||
if (LogJob)
|
||||
JobsBiz.LogJob(JobId, $"Seeder:SeedDatabase error during ops\r\n{ex.Message}");
|
||||
throw ex;
|
||||
}
|
||||
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 string Uniquify(string s)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user