This commit is contained in:
2020-09-21 19:55:35 +00:00
parent c592da4cbf
commit d0dd057a1a
3 changed files with 15 additions and 7 deletions

View File

@@ -243,7 +243,6 @@ IMPORTANT NOTES:
DOCKER / LINUX CHEAT SHEET DOCKER / LINUX CHEAT SHEET
Alpine linux enter container and run shell from docker: Alpine linux enter container and run shell from docker:
docker run -it [container_id] /bin/ash sudo docker exec -it xfer_ayanova_1 ash

View File

@@ -371,7 +371,7 @@ namespace AyaNova.Biz
{ {
log.LogDebug($"Not Windows: setting executable path for chrome to expected '/usr/bin/chromium-browser'"); log.LogDebug($"Not Windows: setting executable path for chrome to expected '/usr/bin/chromium-browser'");
lo.ExecutablePath = "/usr/bin/chromium-browser";//this is the default path for docker based alpine dist, but maybe not others, need to make a config setting likely lo.ExecutablePath = "/usr/bin/chromium-browser";//this is the default path for docker based alpine dist, but maybe not others, need to make a config setting likely
// lo.Args = new string[] { "--no-sandbox" }; // lo.Args = new string[] { "--no-sandbox" };
/* /*
https://github.com/puppeteer/puppeteer/issues/1825 https://github.com/puppeteer/puppeteer/issues/1825
const chromeFlags = [ const chromeFlags = [
@@ -382,7 +382,7 @@ namespace AyaNova.Biz
"--no-zygote" "--no-zygote"
] ]
*/ */
lo.Args = new string[] { "--headless --no-sandbox --disable-gpu --single-process --no-zygote" }; lo.Args = new string[] { "--headless --no-sandbox --disable-gpu --single-process --no-zygote" };
} }
else else
{ {
@@ -394,7 +394,7 @@ namespace AyaNova.Biz
//https://stackoverflow.com/questions/53367966/puppeteer-sharp-still-appear-many-chromium-instance-in-process-task-manager-when //https://stackoverflow.com/questions/53367966/puppeteer-sharp-still-appear-many-chromium-instance-in-process-task-manager-when
log.LogDebug($"Launching headless Chrome now:"); log.LogDebug($"Launching headless Chrome now:");
using (var browser = await Puppeteer.LaunchAsync(lo)) using (var browser = await Puppeteer.LaunchAsync(lo))
using (var page = await browser.NewPageAsync()) using (var page = await browser.NewPageAsync())
{ {
try try
@@ -519,10 +519,15 @@ namespace AyaNova.Biz
//render to pdf and return //render to pdf and return
log.LogDebug($"Calling render page contents to PDF"); log.LogDebug($"Calling render page contents to PDF");
await page.PdfAsync(outputFullPath); await page.PdfAsync(outputFullPath);
//close the browser
// log.LogDebug($"Closing browser");
// await browser.CloseAsync();
log.LogDebug($"Completed, returning results"); log.LogDebug($"Completed, returning results");
return outputFileName; return outputFileName;
} }
catch catch
{ {
//NOTE: in future may need to kill the chromium process if it's found to be hanging around //NOTE: in future may need to kill the chromium process if it's found to be hanging around
//my preliminary thinking is to keep track of the browser.process.processid above and check if still present and zap if so //my preliminary thinking is to keep track of the browser.process.processid above and check if still present and zap if so
@@ -536,6 +541,10 @@ namespace AyaNova.Biz
// var v=await page.GetContentAsync(); // var v=await page.GetContentAsync();
throw; throw;
} }
finally
{
await browser.CloseAsync();
}
} }
} }

View File

@@ -5,7 +5,7 @@ namespace AyaNova.Util
/// </summary> /// </summary>
internal static class AyaNovaVersion internal static class AyaNovaVersion
{ {
public const string VersionString = "8.0.0-alpha.17"; public const string VersionString = "8.0.0-alpha.18";
public const string FullNameAndVersion = "AyaNova server " + VersionString; public const string FullNameAndVersion = "AyaNova server " + VersionString;
}//eoc }//eoc
}//eons }//eons