diff --git a/server/AyaNova/biz/ReportBiz.cs b/server/AyaNova/biz/ReportBiz.cs index 8ff48283..6854c3f2 100644 --- a/server/AyaNova/biz/ReportBiz.cs +++ b/server/AyaNova/biz/ReportBiz.cs @@ -217,7 +217,7 @@ namespace AyaNova.Biz await ValidateCanDelete(dbObject); if (HasErrors) return false; - { + { var IDList = await ct.Review.AsNoTracking().Where(x => x.AType == AyaType.Report && x.ObjectId == id).Select(x => x.Id).ToListAsync(); if (IDList.Count() > 0) { @@ -317,7 +317,7 @@ namespace AyaNova.Biz { //Use Any command is efficient way to check existance, it doesn't return the record, just a true or false //NOTE: unlike other objects reports can have the same name as long as the type differs - if (await ct.Report.AnyAsync(z => z.Name == proposedObj.Name && z.AType==proposedObj.AType && z.Id != proposedObj.Id)) + if (await ct.Report.AnyAsync(z => z.Name == proposedObj.Name && z.AType == proposedObj.AType && z.Id != proposedObj.Id)) { AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name"); } @@ -417,7 +417,7 @@ namespace AyaNova.Biz //Default timeout for each operation of report generation var WaitTimeout = new WaitForFunctionOptions() { Timeout = ServerBootConfig.REPORT_RENDERING_OPERATION_TIMEOUT }; - + //includeWoItemDescendants? reportRequest.IncludeWoItemDescendants = report.IncludeWoItemDescendants; @@ -459,7 +459,16 @@ namespace AyaNova.Biz "--no-zygote" ] */ - lo.Args = new string[] { "--disable-dev-shm-usage --no-sandbox --disable-gpu --single-process --no-zygote " }; + //was using this for a long period of time + //lo.Args = new string[] { "--disable-dev-shm-usage --no-sandbox --disable-gpu --single-process --no-zygote " }; + + //however chrome may be problematic on linux, I'm seeing issues under load testing where it freezes out the droplet at 100% cpu and ram and it's + //chrome processes piling up all churning away so experimenting with resolutions + + //this guy says single process should NOT be used + //https://github.com/puppeteer/puppeteer/issues/1825#issuecomment-792817748 + //testing + lo.Args = new string[] { "--disable-dev-shm-usage --no-sandbox --disable-gpu --no-zygote " }; } else { @@ -479,10 +488,10 @@ namespace AyaNova.Biz using (var page = await browser.NewPageAsync()) { - - + + //see catch block - // var ChromiumProcessID = browser.Process.Id; + var ChromiumProcessID = browser.Process.Id; try { @@ -592,11 +601,11 @@ namespace AyaNova.Biz -// #if (DEBUG) -// //view page contents -// var pagecontent = await page.GetContentAsync(); + // #if (DEBUG) + // //view page contents + // var pagecontent = await page.GetContentAsync(); -// #endif + // #endif //prePareData / preRender var ReportDataObject = $"{{ ayReportData:{ReportData}, ayReportMetaData:{reportMeta}, ayClientMetaData:{clientMeta}, ayServerMetaData:{serverMeta} }}"; log.LogDebug($"Calling ayPreRender..."); @@ -629,7 +638,7 @@ namespace AyaNova.Biz //https://pptr.dev/#?product=Puppeteer&version=v5.3.0&show=api-pagepdfoptions log.LogDebug($"Resolving PDF Options from report settings"); var PdfOptions = new PdfOptions() { }; - + PdfOptions.DisplayHeaderFooter = report.DisplayHeaderFooter; if (report.DisplayHeaderFooter) { @@ -701,6 +710,15 @@ namespace AyaNova.Biz //render to pdf and return log.LogDebug($"Calling render page contents to PDF"); + + //============== TESTING ================= + var process = System.Diagnostics.Process.GetProcessById(ChromiumProcessID); + if (ChromiumProcessID > 0 && process?.HasExited == false) + { + log.LogError($"Error during render, Chromium process (pid {ChromiumProcessID}) still active, forcing it to stop now"); + process.Kill(); + } + //============================================ await page.PdfAsync(outputFullPath, PdfOptions);//###### TODO: SLOW NEEDS TIMEOUT HERE ONCE SUPPORTED, open bug: https://github.com/hardkoded/puppeteer-sharp/issues/1710 log.LogDebug($"Completed, returning results");