Skip to content

Commit

Permalink
Basic "healthcheck" endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacall committed Dec 3, 2024
1 parent 0d648cf commit 360ba86
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/controllers/health_check_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class HealthCheckController < ActionController::Base # :nodoc:
rescue_from(Exception) { render_down }

def show
render_up
end

private
def render_up
render plain: 'up', status: 200
end

def render_down
render plain: 'down', status: 503
end
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@
get 'bioschemas/test' => 'bioschemas#test'
post 'bioschemas/test' => 'bioschemas#run_test'

get 'up' => 'health_check#show'

# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

Expand Down
4 changes: 4 additions & 0 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ services:
target: production
image: ${PREFIX}-app
restart: always
healthcheck:
test: curl -f http://localhost:3000/up
interval: 5s
timeout: 300s
env_file: .env
depends_on:
- db
Expand Down

0 comments on commit 360ba86

Please sign in to comment.