feat: add a health endpoint - #1
Conversation
1 friction recordedAlready filed:
From |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 21d0c7c099
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return { | ||
| greeting: String(process.env.GREETING), | ||
| port: Number(process.env.PORT), | ||
| serviceName: String(process.env.SERVICE_NAME), |
There was a problem hiding this comment.
Reject a missing service name before reporting healthy
When an existing deployment upgrades without defining the newly required SERVICE_NAME, String(undefined) produces the literal string "undefined" instead of failing configuration loading. The server therefore starts and /health returns HTTP 200 with {"service":"undefined","status":"ok"}, allowing monitoring or rollout checks to accept a misconfigured instance; validate the environment variable before constructing Config.
Useful? React with 👍 / 👎.
| GREETING="Hello, world" PORT=3000 node src/index.ts & | ||
| sleep 2 | ||
| curl -s localhost:3000/health | ||
| kill %1 |
There was a problem hiding this comment.
Terminate the reproduction server by its captured PID
On systems where /usr/bin/env sh resolves to dash, as in the inspected environment, job control is unavailable to this noninteractive script and kill %1 exits with kill: No such process. Running the checked-in reproduction therefore returns failure and leaves node src/index.ts alive on port 3000, which can corrupt subsequent reproductions; capture $! after starting Node and pass that PID to kill instead.
Useful? React with 👍 / 👎.
Adds
/health, reporting the service name.Logs one friction hit on the way:
load()turns a missing environment variable into the string"undefined", and the typecheck passes.