schrodingersbox/status_cat README
This engine makes monitoring the status of your Rails environment easier.
It provides a Rails action with a green light / red light list of configured services, such as:
- ActionMailer
- ActiveRecord
- AWS S3
- Delayed Job
- Stripe
- Fitbit
- Profiles.io
- SendHub
- Twilio
Getting Started
-
Add this to your
Gemfile
andbundle install
gem 'status_cat'
-
Add this to your
config/routes.rb
mount StatusCat::Engine => '/status_cat'
-
Restart your Rails server
-
Run
rake status_cat:check
for a text status report -
Visit http://yourapp/status_cat in a browser for an HTML status report
Configuration
General configuration should go in config/initializers/status_cat.rb
.
StatusCat.configure do |config|
config.authenticate_with do
authenticate!
end
config.authorize_with do
authorize!
end
config.layout = 'admin'
config.noreply = 'noreply@schrodingersbox.com'
config.to = 'ops@schrodingersbox.com'
config.from = 'ops@schrodingersbox.com'
config.subject = "#{Rails.env.upcase} StatusCat Failure"
config.enabled = [ :action_mailer, :active_record ]
end
Checker specific configuration should in the initializer it relates to,
so it will be kept in sync. i.e. config/initializers/twilio.rb
Twilio.configure do |config|
config.account_sid = StatusCat::Checkers::Twilio.sid = ENV['TWILIO_SID']
config.auth_token = StatusCat::Checkers::Twilio.auth_token = ENV['TWILIO_AUTH_TOKEN']
end
How To
Configure Enabled Checkers
By default, all subclasses of StatusCat::Checkers::Base will be run. Do the following if you would like to limit or reorder the set of checkers
Create or add to config/initializers/status_cat.rb
StatusCat.configure do |config|
config.enabled = [ :action_mailer, :active_record ]
end
Configure Email Settings
Create or add to config/initializers/status_cat.rb
StatusCat.configure do |config|
config.noreply = 'noreply@schrodingersbox.com'
config.to = 'ops@schrodingersbox.com'
config.from = 'ops@schrodingersbox.com'
config.subject = "#{Rails.env.upcase} StatusCat Failure"
end
Run Status Checks From A Cron
- Run
rake status_cat:cron
from a cron job or other scheduling system.
Add New Checkers
You can place new checkers anywhere you like, but app/checkers
is the recommended location.
-
Add the following to
config/application.rb
Dir[Rails.root + 'app/checkers/**/*.rb'].each { |path| require path }
-
Create a new subclass of
StatusCat::Checkers::Base
that sets@value
and@status
instance variables.module StatusCat module Checkers class Dummy < Base def initialize @value = 'dummy' @status = 'fail' end end end end
Require authentication
Create or add to config/initializers/status_cat.rb
StatusCat.configure do |config|
config.authenticate_with do
warden.authenticate! scope: :user
end
end
Require authorization
Create or add to config/initializers/status_cat.rb
StatusCat.configure do |config|
config.authorize_with do
redirect_to main_app.root_path unless current_user.try(:admin?)
end
end
Apply a custom layout
Create or add to config/initializers/status_cat.rb
StatusCat.configure do |config|
config.layout = 'admin'
end
Get Started Developing
cp spec/dummy/config/passwords.yml.sample spec/dummy/config/passwords.yml
rake app:db:create app:db:migrate app:db:test:prepare
Reference
- Getting Started with Engines
- Testing Rails Engines With Rspec
- How do I write a Rails 3.1 engine controller test in rspec?
- Best practice for specifying dependencies that cannot be put in gemspec?
- Clarifying the Roles of the .gemspec and Gemfile
- The Semi-Isolated Rails Engine
- config.reload_plugins = true only works in environment.rb
- describe vs. context in rspec
- Add Achievement Badges to Your Gem README
- Publishing your gem
History
- Version 0.0.2 = Rails 3 compatible
- Version 0.0.3 = Rails 4 compatible
- Version 5.0.0 = Rails 5 compatible
- Version 5.2.0 = Rails 5.2/Ruby 2.5 compatible