5

Render requires a /health endpoint, but when I create this in my app & deploy for the first time, I am unable to deploy because the app cannot boot without the migrations having run first.

it seems that Render.com health check needs the health endpoint to respond OK even before the migrations have run. how can I achieve this?

Jason FB
  • 4,752
  • 3
  • 38
  • 69

3 Answers3

17

For Rails 6 and below, you can directly write this in routes file

get '/health_check', to: proc { [200, {}, ['success']] }

Jason FB
  • 4,752
  • 3
  • 38
  • 69
adityapandit17
  • 356
  • 1
  • 8
2

You can use rails-healthcheck (https://github.com/linqueta/rails-healthcheck) gem to it simple:

Install the gem and run the generator rails g healthcheck:install and call /healthcheck and voilà!

linqueta
  • 31
  • 1
1

Rails 7 now provides a default health check controller.

We can now visit /up to check whether the app is running. If the application is healthy, it will return a 200 status code. Else, it will return a 503 status code (https://blog.saeloun.com/2023/02/27/rails-introduces-default-health-check-controller/#:~:text=With%20the%20latest%20changes%2C%20we,return%20a%20200%20status%20code)