Purple-Devs / health_check

Simple health check of Rails app for use with uptime checking sites like newrelic and pingdom
MIT License
477 stars 127 forks source link

use middleware to catch Rails stack exceptions #52

Closed lowang closed 7 years ago

lowang commented 8 years ago

No Rails stack problems, health check goes to controller:

Started GET "/health_check" for 127.0.0.1 at 2016-10-19 13:06:05 +0200
  ActiveRecord::SchemaMigration Load (54.8ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by HealthCheck::HealthCheckController#index as HTML
  ActiveRecord::SchemaMigration Load (0.3ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  CACHE (0.0ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  Rendered text template (0.0ms)
Completed 200 OK in 53ms (Views: 8.8ms | ActiveRecord: 1.6ms)

DB connection problem occured, middleware catches exception:

Started GET "/health_check" for 127.0.0.1 at 2016-10-19 13:08:55 +0200
Completed 500 Failure in 21.14231511950493ms

and displays nice message:

health_check failed: could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
ianheggie commented 8 years ago

I like the idea, but would need to rework the code as it conflicts with other PR's. I intend to get back to this when I have finished the other changes.

ianheggie commented 7 years ago

Thanks for the idea and code - I have used it indirectly in the current version rather than directly merging the code, so I am closing this pull request with thanks