From fc99cc51c203563bbba5ae9b9f4cb81a985df90d Mon Sep 17 00:00:00 2001 From: Phil Wilson Date: Wed, 4 Sep 2024 15:36:18 +0100 Subject: [PATCH] Add AUTO_REFRESH environment variable Change-type: minor Signed-off-by: Phil Wilson --- readme.md | 1 + src/server.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/readme.md b/readme.md index f2a16bb..831e3bb 100644 --- a/readme.md +++ b/readme.md @@ -92,6 +92,7 @@ The following environment variables allow configuration of the `browser` block: |`WINDOW_POSITION`|`x,y`|`0,0`|Specifies the browser window position on the screen| |`API_PORT`|port number|5011|Specifies the port number the API runs on| |`REMOTE_DEBUG_PORT`|port number|35173|Specifies the port number the chrome remote debugger runs on| +|`AUTO_REFRESH`|interval|0 (disabled)|Specifies the number of seconds before the page automatically refreshes| --- diff --git a/src/server.js b/src/server.js index 0094706..79c8031 100644 --- a/src/server.js +++ b/src/server.js @@ -22,6 +22,7 @@ const REMOTE_DEBUG_PORT = process.env.REMOTE_DEBUG_PORT || 35173; const FLAGS = process.env.FLAGS || null; const EXTRA_FLAGS = process.env.EXTRA_FLAGS || null; const HTTPS_REGEX = /^https?:\/\//i //regex for HTTP/S prefix +const AUTO_REFRESH = process.env.AUTO_REFRESH || 0; // Environment variables which can be overriden from the API let kioskMode = process.env.KIOSK || '0'; @@ -182,6 +183,7 @@ async function SetDefaultFlags() { } async function setTimer(interval) { + console.log("Auto refresh interval: ", interval); timer = setIntervalAsync( async () => { try { @@ -204,6 +206,10 @@ async function main(){ await SetDefaultFlags(); let url = await getUrlToDisplayAsync(); await launchChromium(url); + if (AUTO_REFRESH > 0) + { + await setTimer(AUTO_REFRESH * 1000); + } }