Critical health check, but app not restarting?

Had my health checks failing and my application totally down, but wouldn’t come back up until I manually triggered a redeploy.

Is there any way with v2 apps to automatically restart on failed health checks? It’s what I set up health checks for in the first place; surprised that this isn’t default behavior.

Thanks

Hi!

Health checks instruct the Fly.io proxy to stop routing requests to that particular machine if the health check fails. The assumption is that you’d have other machines in your app ready to handle those requests (redundancy!). There is currently no direct way to ask the proxy to “restart a machine on failed health check”.

However, since health checks are provided by your application itself, the application can be in control of whether to restart the machine. Under the default restart policy, if your application exits with a non-zero exit code, the machine will be restarted.

So in the endpoint where your application does the health check, you can add something like “ok, I’m unhealthy, let’s just exit so I get rebooted”. Once the machine comes back, if it did help and the health check starts passing, it will start receiving requests again.

I think that should achieve what you mentioned.

Cheers,

  • Daniel

So in the endpoint where your application does the health check, you can add something like “ok, I’m unhealthy, let’s just exit so I get rebooted”.

I’m not sure my application was responsive at all, so not sure this would help.
Don’t seem to have the logs handy to confirm what actually happened, though.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.