// Launch a Chromium instance via puppeteer-core and print the WebSocket endpoint to stdout // Also write the launcher PID to /tmp/puppeteer_chrome_launcher.pid const fs = require('fs'); (async () => { try { const puppeteer = require('puppeteer-core'); const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'], }); const ws = browser.wsEndpoint(); const pidFile = '/tmp/puppeteer_chrome_launcher.pid'; try { fs.writeFileSync(pidFile, String(process.pid)); } catch(e) { } console.log('PUPPETEER_WS=' + ws); console.log('LAUNCHER_PID=' + process.pid); // keep process alive until killed process.on('SIGINT', async () => { try { await browser.close(); } catch(e){}; process.exit(0); }); process.on('SIGTERM', async () => { try { await browser.close(); } catch(e){}; process.exit(0); }); // prevent exit await new Promise(() => {}); } catch (err) { console.error('LAUNCH_ERROR', String(err)); process.exit(2); } })();