From fb8cdd4bce1c549135b435473b5ca30e77efa969 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 14 Nov 2020 18:08:26 +0300 Subject: feat: configure headless mode --- src/handlers/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/handlers/index.js b/src/handlers/index.js index d4eaf43..e6f84df 100644 --- a/src/handlers/index.js +++ b/src/handlers/index.js @@ -5,7 +5,10 @@ const launchUserSession = require('./launchUserSession.js'); const attendConference = require('./attendConference.js'); const { clickElementBySelector } = require('./utils.js'); -const { EDUFPMI_URL } = process.env; +const { EDUFPMI_URL, NODE_ENV, HEADLESS } = process.env; + +// Always run headless in production, but allow configuring for development +const headless = NODE_ENV === 'production' || HEADLESS || false; const handleJobAsUser = async (job, user) => { @@ -14,7 +17,7 @@ const handleJobAsUser = async (job, user) => { const { conferenceId } = job.attrs.data; const conferenceUrl = `${EDUFPMI_URL}/mod/bigbluebuttonbn/view.php?id=${conferenceId}`; - const browser = await launchUserSession(user, false); + const browser = await launchUserSession(user, headless); const page = await browser.newPage(); await page.goto(conferenceUrl); -- cgit v1.2.3