Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AUTO_REFRESH environment variable #178

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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