Ready to know about downtime before your customers?
Status List delivers uptime monitoring and professional hosted status pages for sites of all shapes and sizes.
Trusted by 1000+ companies
You need to know if your Rails application is working. Rails health checks allows your app to self heal and notify you about issues. Let’s set it up!
This guide uses the Rails-Healthcheck gem. If you would rather use the built-in Rails::HealthController, please refer to our Rails Health Check Setup Guide.
gem 'rails-healthcheck'
rails generate healthcheck:install
.route
property to /up
. Set verbose=true
to we can diagnose any errors. Save your changes and restart your app. Open 127.0.0.1:3000/up. You should get an output that looks like this: Trusted by 1000+ companies
config.add_check :database, -> { ActiveRecord::Base.connection.execute('select 1') }
config.add_check :migrations, -> { ActiveRecord::Migration.check_pending! }
config.add_check :cache, -> { Rails.cache.read('some_key') }
config.add_check :mail_service, -> {
response = Net::HTTP.get_response(URI.parse("https://api.mailgun.net/v3/mydomain.com/stats"), {
'Authentication' => ENV['MAILGUN_API_KEY'],
})
return response.error!
}
Once you have your checks setup, it’s time to setup your uptime monitor. Log into your uptime service and add monitors for both of your services. You’ll want to check both /health/app and /health/upstream separately. You may also want to configure a minimum response time for /health/app to ensure your app is responsive.
You may also want to show your app’s status on your status page. Ensure you update your status page configuration to pull your uptime stats in to your status page.
You now have uptime checks and alerts for your Rails application. If your app runs into issues you’ll be the first to know.
You may also be interested in our Heroku Uptime Service.
© Status List 2024