health endpoint
digi604
PROOP

8 months ago

we have a project with a backend and 5 workers nodes. they all use the same checkout path from the git repo. the backend should have a health endpoint... but if i enable this: all workers get this endpoint as well and fail deployment. I can also not select the "Service" here as it is Zenline App service.. and i am not admin there.

$30 Bounty

2 Replies

Railway
BOT

8 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open Railway • 8 months ago


hyper674
PRO

8 months ago

Easiest fix is to wrap the health endpoint behind an env var check. Something like:

```javascript

if (process.env.SERVICE_TYPE === 'backend') {

app.get('/health', (req, res) => res.status(200).send('ok'));

}

```

Then just set SERVICE_TYPE=backend on the backend service in Railway and leave it unset on the workers. Workers won't spin up the endpoint, so the health check won't apply to them.

For the workers themselves, go into each one's settings and set the health check to "None" since they're not running an HTTP server anyway.

If you don't have access to change the health check settings, the env var approach alone should work just make sure the workers aren't trying to bind to a port at all.


ardaerturk
FREE

2 days ago

There are two separate settings here: whether the application exposes an HTTP route, and whether Railway probes that route during deployment.

An environment-variable check around app.get('/health', ...) changes only the application. It does not disable a healthcheck already configured for that Railway service. With that check still configured, making a worker stop serving HTTP will still leave its deployment waiting for a successful healthcheck.

The backend should have the healthcheck path configured; each worker should have its Healthcheck Path cleared in that worker's deployment settings.

If a shared railway.json or railway.toml contains deploy.healthcheckPath, check that first. Railway's documentation says config-file values override the dashboard without updating the displayed service settings. Sharing that file can therefore make a dashboard-only change ineffective. The deployment details' file icon shows where a value came from. Keep the healthcheck configuration specific to the backend instead of applying that field to every worker.

Because you mentioned lacking access to the service settings, the project administrator needs to make the relevant configuration change. A JavaScript environment-variable condition cannot substitute for that permission.

Sources:

AI-assisted; checked against the current Railway documentation. I have not inspected or changed your project.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...