Disable sandbox only if running inside a container

This commit is contained in:
Nemo 2018-06-04 13:31:04 +05:30
parent 69471cb901
commit 5e379ff173
3 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,5 @@
const puppeteer = require('puppeteer');
const containerized = require('containerized');
const MY_PACKAGE_SELECTOR_ID =
'table[style="margin-top:-10px;"] tr:first-child+tr';
@ -36,8 +37,14 @@ async function getUsage() {
}
function chromeLaunchConfig() {
let defaultArgs = [];
if (containerized()) {
defaultArgs = ['--no-sandbox', '--disable-setuid-sandbox'];
}
var options = {
args: ['--no-sandbox', '--disable-setuid-sandbox'].concat(
// These are set for Docker usage
// https://github.com/alekzonder/docker-puppeteer#before-usage
args: defaultArgs.concat(
process.env.hasOwnProperty('PROXY_SERVER')
? [`--proxy-server=${process.env['PROXY_SERVER']}`]
: []

5
package-lock.json generated
View File

@ -57,6 +57,11 @@
"typedarray": "^0.0.6"
}
},
"containerized": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/containerized/-/containerized-1.0.2.tgz",
"integrity": "sha1-3+0xSeq1BC7wsG6FHH2PTcZ1DYg="
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",

View File

@ -6,10 +6,15 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": ["actcorp", "balance", "flexibyte"],
"keywords": [
"actcorp",
"balance",
"flexibyte"
],
"author": "Nemo <npm@captnemo.in>",
"license": "MIT",
"dependencies": {
"containerized": "^1.0.2",
"prom-client": "^11.0.0",
"puppeteer": "^1.4.0"
}