Skip to content

Commit

Permalink
Add AUTO_REFRESH environment variable
Browse files Browse the repository at this point in the history
Change-type: minor
Signed-off-by: Phil Wilson <[email protected]>
  • Loading branch information
phil-d-wilson committed Sep 4, 2024
1 parent a410cbb commit fc99cc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|

---

Expand Down
6 changes: 6 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -182,6 +183,7 @@ async function SetDefaultFlags() {
}

async function setTimer(interval) {
console.log("Auto refresh interval: ", interval);
timer = setIntervalAsync(
async () => {
try {
Expand All @@ -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);
}
}


Expand Down

0 comments on commit fc99cc5

Please sign in to comment.