Skip to content
mperham edited this page Apr 27, 2012 · 27 revisions

Sidekiq comes with a Sinatra application that can display the current state of a Sidekiq installation.

Rails 3

Add slim and sinatra (and sprockets if you are on Rails 3.0) to your Gemfile

Add the following to your config/routes.rb:

  require 'sidekiq/web'
  mount Sidekiq::Web => '/sidekiq'

In a production application you'll likely want to protect access to this information. You can use the constraints feature of routing to accomplish this:

constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
constraints constraint do
  mount Sidekiq::Web => '/sidekiq'
end

The above example uses Devise and checks a User model instance that responds to admin?. Here's an example using Authlogic:

# lib/admin_constraint.rb
class AdminConstraint
  def matches?(request)
    return false unless request.cookies['user_credentials'].present?
    user = User.find_by_persistence_token(request.cookies['user_credentials'].split(':')[0])
    user && user.admin?
  end
end

# config/routes.rb
mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new

Standalone

Here's an example config.ru for booting Sidekiq::Web in your choice of Rack server:

require 'sidekiq'

Sidekiq.configure_client do |config|
  config.redis = { :size => 1 }
end

require 'sidekiq/web'
run Sidekiq::Web

If you do everything right, you should see this in your browser:

Web UI

Clone this wiki locally