Skip to content
Merged
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
4 changes: 2 additions & 2 deletions scripts/healthcheck.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

/**
* Docker healthcheck script for OmniRoute.
* Checks the /api/settings endpoint on the dashboard port.
* Checks the /api/monitoring/health endpoint on the dashboard port.
* Used by Dockerfile and docker-compose files.
*/
const port = process.env.DASHBOARD_PORT || process.env.PORT || "20128";

fetch(`http://127.0.0.1:${port}/api/settings`)
fetch(`http://127.0.0.1:${port}/api/monitoring/health`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's good practice to add a timeout to the fetch request within the healthcheck script. This ensures the script exits cleanly if the server is unresponsive, rather than relying on Docker's healthcheck timeout to kill the process. A timeout slightly less than Docker's configured 5 seconds (e.g., 4 seconds) is ideal.

Suggested change
fetch(`http://127.0.0.1:${port}/api/monitoring/health`)
fetch(`http://127.0.0.1:${port}/api/monitoring/health`, { signal: AbortSignal.timeout(4000) })

.then((r) => {
if (!r.ok) throw new Error(`HTTP ${r.status}`);
})
Expand Down
Loading