Add readiness check web endpoint
Some checks failed
Gitea Actions Demo / lint (push) Failing after 1m21s
Gitea Actions Demo / test (push) Has been skipped
Gitea Actions Demo / release-image (push) Has been skipped

This commit is contained in:
Ryan Cavicchioni 2024-07-27 16:41:16 -05:00
parent f131f64641
commit 3de520eda0
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D

12
app.rb
View File

@ -226,10 +226,10 @@ get "/headers", provides: "json" do
JSON.generate h JSON.generate h
end end
get "/livez" do get '/livez' do
error 503 unless Health.instance.healthy? error 503 unless Health.instance.healthy?
return Health.instance.to_json if request.env["HTTP_ACCEPT"] == "application/json" return Health.instance.to_json if request.env['HTTP_ACCEPT'] == 'application/json'
Health.instance.to_s Health.instance.to_s
end end
@ -250,6 +250,14 @@ post "/livez/sleep" do
"ok\n" "ok\n"
end end
get '/readyz' do
error 503 unless Ready.instance.healthy?
return Ready.instance.to_json if request.env['HTTP_ACCEPT'] == 'application/json'
Ready.instance.to_s
end
get "/uuid" do get "/uuid" do
n = params.fetch(:n, 1).to_i n = params.fetch(:n, 1).to_i
stream do |out| stream do |out|