mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Add healthcheck endpoint, spec testing
This commit is contained in:
parent
4d06c01d21
commit
08132f75bd
4 changed files with 76 additions and 2 deletions
|
|
@ -3,7 +3,7 @@
|
|||
module Vmpooler
|
||||
class API < Sinatra::Base
|
||||
# Load API components
|
||||
%w[helpers dashboard reroute v1 request_logger].each do |lib|
|
||||
%w[helpers dashboard reroute v1 request_logger healthcheck].each do |lib|
|
||||
require "vmpooler/api/#{lib}"
|
||||
end
|
||||
# Load dashboard components
|
||||
|
|
@ -40,6 +40,10 @@ module Vmpooler
|
|||
require 'prometheus/middleware/exporter'
|
||||
use Vmpooler::Metrics::Promstats::CollectorMiddleware, metrics_prefix: "#{metrics.prometheus_prefix}_http"
|
||||
use Prometheus::Middleware::Exporter, path: metrics.prometheus_endpoint
|
||||
# Note that a user may want to use this check without prometheus
|
||||
# However, prometheus setup includes the web server which is required for this check
|
||||
# At this time prometheus is a requirement of using the health check on manager
|
||||
use Vmpooler::API::Healthcheck
|
||||
end
|
||||
|
||||
if torun.include? :api
|
||||
|
|
|
|||
14
lib/vmpooler/api/healthcheck.rb
Normal file
14
lib/vmpooler/api/healthcheck.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Vmpooler
|
||||
class API
|
||||
class Healthcheck < Sinatra::Base
|
||||
get '/healthcheck/?' do
|
||||
content_type :json
|
||||
|
||||
status 200
|
||||
JSON.pretty_generate({ 'ok' => true })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue