app: add /healthz liveness endpoint
This commit is contained in:
parent
9485b6b72a
commit
afde73e772
2 changed files with 18 additions and 0 deletions
12
asxpio.rb
12
asxpio.rb
|
|
@ -143,6 +143,18 @@ class AsxpioWeb < Sinatra::Base
|
||||||
redirect '/thanks'
|
redirect '/thanks'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Liveness for the Docker HEALTHCHECK and the deploy pipeline. Pings the DB
|
||||||
|
# when invoicing is configured — a wedged connection pool should read as
|
||||||
|
# unhealthy, not just "process exists".
|
||||||
|
get '/healthz' do
|
||||||
|
begin
|
||||||
|
DB.connection['SELECT 1'].get if defined?(Invoice)
|
||||||
|
rescue Sequel::Error
|
||||||
|
halt 503, 'db unreachable'
|
||||||
|
end
|
||||||
|
'ok'
|
||||||
|
end
|
||||||
|
|
||||||
get '/thanks' do
|
get '/thanks' do
|
||||||
@page_title = 'Thanks — IE Sergei Poljanski'
|
@page_title = 'Thanks — IE Sergei Poljanski'
|
||||||
@page_desc = 'Your message has been received. A confirmation copy has been sent to your inbox.'
|
@page_desc = 'Your message has been received. A confirmation copy has been sent to your inbox.'
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,12 @@ class AppTest < Minitest::Test
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_healthz
|
||||||
|
get '/healthz'
|
||||||
|
assert last_response.ok?
|
||||||
|
assert_equal 'ok', last_response.body
|
||||||
|
end
|
||||||
|
|
||||||
# --- contact form ---------------------------------------------------------
|
# --- contact form ---------------------------------------------------------
|
||||||
|
|
||||||
def contact_params(over = {})
|
def contact_params(over = {})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue