-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser-server.js
More file actions
27 lines (23 loc) · 856 Bytes
/
browser-server.js
File metadata and controls
27 lines (23 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const puppeteer = require('puppeteer');
const fs = require('fs');
(async () => {
console.log('Launching browser...');
const browser = await puppeteer.launch({
headless: 'shell',
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-gpu',
'--remote-debugging-port=9222',
'--remote-debugging-address=127.0.0.1',
],
});
const wsEndpoint = browser.wsEndpoint();
const wsPath = new URL(wsEndpoint).pathname;
fs.writeFileSync('/tmp/browser-info.json', JSON.stringify({ wsEndpoint, wsPath }));
console.log('BROWSER_READY');
console.log('WS_PATH=' + wsPath);
process.on('SIGTERM', async () => { await browser.close(); process.exit(0); });
setInterval(() => {}, 60000);
})();