/stoplight-admin

A simple administration interface for the stoplight gem.

Primary LanguageRubyMIT LicenseMIT

Gem version

A simple administration interface for stoplight. Monitor the status, failures, and invocations of your stoplights. Change stoplight colors, or lock them in either red or green state.

The stoplight-admin version 0.4 and above is only compatible with Stoplight 4.1. If you have Stoplight version below 4.0, use stoplight-admin 0.3.6.

Configuration

This project is packaged as a Ruby gem so that you can easily embed it in your own code containing the configuration details for your stoplight data store.

First you'll need a Gemfile:

source 'https://rubygems.org'

gem 'stoplight-admin'

Run Bundler to install the dependencies:

$ bundle install

Lastly we need to make our (tiny) application. Here's a typical example using a local Redis data store:

# app.rb

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'

  gem 'redis'
  gem 'stoplight-admin'
  gem 'webrick'
end

require 'redis'
require 'sinatra'
require 'stoplight_admin/application'

redis = Redis.new(url: 'redis://localhost:6379')
set :data_store, Stoplight::DataStore::Redis.new(redis)

Reverse Proxying

If you run Stoplight Admin behind a reverse proxy (nginx, for instance) at a URL other than root, you'll need to add the following lines to your app.rb file:

use Rack::Config do |env|
  env['SCRIPT_NAME'] = '/your/prefix/here'
end

Usage

$ bundle exec ruby app.rb

Rails

It is possible to mount Stoplight Admin inside Rails. Add something like this to your config/routes.rb:

require 'redis'
require 'stoplight_admin/application'

class StoplightAdminApp < Sinatra::Base
  register StoplightAdmin::Application

  redis = Redis.new # Uses REDIS_URL environment variable.
  data_store = Stoplight::DataStore::Redis.new(redis)
  set :data_store, data_store
end

Rails.application.routes.draw do
  mount StoplightAdminApp => '/stoplights'
end

Credits

Stoplight is brought to you by @camdez and @tfausak from @OrgSync.