Enabled puppeteer cluster
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
104eea2e4f
commit
785e7aa9fa
|
@ -2,7 +2,7 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const config = require('./config');
|
||||
const Component = require('./component');
|
||||
const puppeteer = require('puppeteer');
|
||||
const Cluster = require('./cluster');
|
||||
|
||||
if (!process.env.OPENSSL_CONF)
|
||||
process.env.OPENSSL_CONF = '/etc/ssl/';
|
||||
|
@ -32,17 +32,8 @@ class Report extends Component {
|
|||
if (fs.existsSync(fullPath))
|
||||
options = require(optionsPath);
|
||||
|
||||
const browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
'--single-process',
|
||||
'--no-zygote'
|
||||
]
|
||||
});
|
||||
|
||||
const page = (await browser.pages())[0];
|
||||
return new Promise(resolve => {
|
||||
Cluster.pool.queue({}, async({page}) => {
|
||||
await page.emulateMediaType('screen');
|
||||
await page.setContent(template);
|
||||
|
||||
|
@ -60,11 +51,11 @@ class Report extends Component {
|
|||
options.headerTemplate = '\n';
|
||||
options.footerTemplate = footer;
|
||||
|
||||
const buffer = await page.pdf(options);
|
||||
const stream = await page.pdf(options);
|
||||
|
||||
await browser.close();
|
||||
|
||||
return buffer;
|
||||
resolve(stream);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue