From a444b85ff31cb0f49a8fabb1f5a7eb55b9d37ec7 Mon Sep 17 00:00:00 2001 From: godsavethequeen23159-star Date: Thu, 11 Dec 2025 22:48:58 +0000 Subject: [PATCH 1/3] Bind server to 0.0.0.0 for container/remote access --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 896be226fc..e47c8f699c 100644 --- a/index.js +++ b/index.js @@ -138,4 +138,5 @@ server.on("listening", () => { console.log(chalk.green(`🌍 Server is running on http://localhost:${PORT}`)); }); -server.listen({ port: PORT }); +// Bind to all interfaces so the app is reachable from the container/host +server.listen({ port: PORT, host: "0.0.0.0" }); From a0faa1c3af7a23ac8ebe7b6126c59d3fece684ef Mon Sep 17 00:00:00 2001 From: godsavethequeen23159-star Date: Thu, 11 Dec 2025 22:55:21 +0000 Subject: [PATCH 2/3] Add .env.example and /healthz endpoint --- .env.example | 19 +++++++++++++++++++ index.js | 9 +++++++++ 2 files changed, 28 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000..01cc2950be --- /dev/null +++ b/.env.example @@ -0,0 +1,19 @@ +# Example environment variables for Interstellar + +# Port to listen on (defaults to 8080 in code) +PORT=8080 + +# If enabled, MASQR integration is active (see README and Masqr.js) +# Set to "true" to enable license validation and Masqr features +MASQR=false + +# Use this env flag to enable password protection per README instructions +# The project uses `config.js` as the primary config; you can set this env if you prefer +# (some deployment setups use it). If your runtime respects this, set to "true". +CONFIG=false + +# Example: set to run behind a specific host/IP if needed +HOST=0.0.0.0 + +# Node environment +NODE_ENV=development diff --git a/index.js b/index.js index e47c8f699c..165bcc8e1a 100644 --- a/index.js +++ b/index.js @@ -102,6 +102,15 @@ const routes = [ { path: "/", file: "index.html" }, ]; +// Health-check endpoint +app.get("/healthz", (_req, res) => { + try { + const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8")); + res.json({ status: "ok", uptime: process.uptime(), version: pkg.version }); + } catch (err) { + res.status(500).json({ status: "error", error: err.message }); + } +}); // biome-ignore lint: idk routes.forEach(route => { app.get(route.path, (_req, res) => { From 7c8eb83860da34fac698840f654422351162acbb Mon Sep 17 00:00:00 2001 From: godsavethequeen23159-star Date: Thu, 11 Dec 2025 23:05:05 +0000 Subject: [PATCH 3/3] Add Docker HEALTHCHECK, docs, CI health-check workflow, and k8s probes --- .github/workflows/health-check.yml | 0 Dockerfile | 6 ++++++ README.md | 13 +++++++++++++ k8s/deployment.yaml | 0 4 files changed, 19 insertions(+) create mode 100644 .github/workflows/health-check.yml create mode 100644 k8s/deployment.yaml diff --git a/.github/workflows/health-check.yml b/.github/workflows/health-check.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Dockerfile b/Dockerfile index ced0eef1db..f78c566961 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,4 +9,10 @@ RUN npm install COPY . . +# Expose port and add a lightweight healthcheck +EXPOSE 8080 + +HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ + CMD curl -f http://localhost:8080/healthz || exit 1 + CMD [ "node", "index.js" ] \ No newline at end of file diff --git a/README.md b/README.md index 12f29164e5..bf451e17e2 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,19 @@ As of January 1st, 2024, Replit is [no longer free](https://blog.replit.com/host 5. Access the deployed website from the ports tab. 6. For subsequent uses in the same codespace, just run `pnpm start` +### Health checks + +This repository exposes a simple health endpoint at `/healthz` which returns a JSON object with `status`, `uptime`, and the package `version`. The endpoint is used by the included Dockerfile `HEALTHCHECK` and by Kubernetes liveness/readiness probes. + +Docker `HEALTHCHECK` example (included in this repo): + +``` +HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ + CMD curl -f http://localhost:8080/healthz || exit 1 +``` + +Use `/healthz` in monitoring, load balancers, and container orchestrators to verify the service is healthy. + ### Solution for if there is no popup. 1. Run `pnpm i`, and before `pnpm start`, prepend `PORT=8080`, replacing 8080 with another port. For example, `PORT=6969 pnpm start`. diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml new file mode 100644 index 0000000000..e69de29bb2