Skip to content

Commit

Permalink
Merge pull request #81 from yorch/path-config
Browse files Browse the repository at this point in the history
Add path config
  • Loading branch information
lbeder committed Mar 14, 2022
2 parents 8fa359b + 9c21b46 commit 9503eb4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -328,6 +328,18 @@ HealthMonitor.configure do |config|
end
```

### Customizing the path

By default, the endpoint where the status page is served is `/check`, but this can be customized:

```ruby
HealthMonitor.configure do |config|
config.path = :status
end
```

This will make the page to be served in the `/status` endpoint for instance (from where the engine was mounted).

### Monitoring Script

A Nagios/Shinken/Icinga/Icinga2 plugin is available in `extra` directory.
Expand Down
11 changes: 8 additions & 3 deletions config/routes.rb
@@ -1,7 +1,12 @@
# frozen_string_literal: true

HealthMonitor::Engine.routes.draw do
controller :health do
get :check
end
path =
if HealthMonitor.configuration.path.present?
HealthMonitor.configuration.path
else
:check
end

get path, to: 'health#check'
end
5 changes: 4 additions & 1 deletion lib/health_monitor/configuration.rb
Expand Up @@ -4,7 +4,10 @@ module HealthMonitor
class Configuration
PROVIDERS = %i[cache database delayed_job redis resque sidekiq].freeze

attr_accessor :error_callback, :basic_auth_credentials, :environment_variables
attr_accessor :basic_auth_credentials,
:environment_variables,
:error_callback,
:path
attr_reader :providers

def initialize
Expand Down
1 change: 1 addition & 0 deletions spec/lib/health_monitor/configuration_spec.rb
Expand Up @@ -9,6 +9,7 @@
it { expect(subject.providers).to eq(default_configuration) }
it { expect(subject.error_callback).to be_nil }
it { expect(subject.basic_auth_credentials).to be_nil }
it { expect(subject.path).to be_nil }
end

describe 'providers' do
Expand Down

0 comments on commit 9503eb4

Please sign in to comment.