Sha256: 473c7c93bae9931afb65b766eec24048f7591e821b168d3120afa413ebb4e5dc

Contents?: true

Size: 627 Bytes

Versions: 2

Compression:

Stored size: 627 Bytes

Contents

# frozen_string_literal: true

class HeyDoctor::CheckApplicationHealthService
  class << self
    SUCCESS = {
      message: 'Application is running',
      success: true
    }.freeze

    ERROR = {
      message: 'Application down, call the firefighters',
      success: false
    }.freeze

    def call
      return SUCCESS if responding?

      ERROR
    end

    private

    def responding?
      app_http_code == '200'
    rescue StandardError
      false
    end

    def app_http_code
      Net::HTTP.start('localhost', ENV['RAILS_PORT']) do |http|
        http.head('/_ah/app_health')
      end.code
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hey_doctor-1.1.2 app/services/hey_doctor/check_application_health_service.rb
hey_doctor-1.1.1 app/services/hey_doctor/check_application_health_service.rb