Permalink
Browse files

Implement simple home page and queue page

  • Loading branch information...
1 parent 20e51f1 commit 0bfe2bd416ae253aa5454581fda1ff6a54e21497 @mperham mperham committed Mar 6, 2012
Showing with 79 additions and 18 deletions.
  1. +8 −0 config.ru
  2. +22 −0 lib/sidekiq/web.rb
  3. +2 −2 myapp/config/initializers/sidekiq.rb
  4. +26 −4 web/views/index.slim
  5. +10 −12 web/views/layout.slim
  6. +11 −0 web/views/queue.slim
View
@@ -0,0 +1,8 @@
+require 'sidekiq'
+
+Sidekiq.configure_client do |config|
+ config.redis = { :size => 1 }
+end
+
+require 'sidekiq/web'
+run Sidekiq::Web
View
@@ -32,11 +32,33 @@ class Web < Sinatra::Base
dir = File.expand_path(File.dirname(__FILE__) + "/../../web")
set :views, "#{dir}/views"
set :root, "#{dir}/public"
+ set :slim, :pretty => true
use SprocketsMiddleware, :root => dir
+ helpers do
+ def workers
+ Sidekiq.redis.smembers('workers')
+ end
+ def queues
+ Sidekiq.redis.smembers('queues')
+ end
+ def location
+ Sidekiq.redis.client.location
+ end
+ def root_path
+ "#{env['SCRIPT_NAME']}/"
+ end
+ end
+
get "/" do
slim :index
end
+
+ get "/queues/:name" do
+ @name = params[:name]
+ @messages = Sidekiq.redis.lrange("queue:#{params[:name]}", 0, 10).map { |str| MultiJson.decode(str) }
+ slim :queue
+ end
end
end
@@ -1,6 +1,6 @@
Sidekiq.configure_client do |config|
- config.redis = { :namespace => 'resque', :size => 2 }
+ config.redis = { :size => 2 }
end
Sidekiq.configure_server do |config|
- config.redis = { :namespace => 'resque', :size => 25 }
+ config.redis = { :size => 25 }
end
View
@@ -1,5 +1,27 @@
header
- h1 Index
-div class="row"
- div class="span12"
- | Index goes here
+ h1 Overview
+
+.tabbable
+ ul.nav.nav-tabs
+ li.active
+ a href="#queues" data-toggle="tab" Queues
+ li
+ a href="#workers" data-toggle="tab" Workers
+ .tab-content
+ #queues.tab-pane.active
+ table class="table table-striped table-bordered"
+ tr
+ th Queue
+ - queues.each do |queue|
+ tr
+ td
+ a href="queues/#{queue}" #{queue}
+
+ #workers.tab-pane
+ table class="table table-striped table-bordered"
+ tr
+ th Workers
+ - workers.each do |worker|
+ tr
+ td
+ a href="workers/#{worker}" #{worker}
View
@@ -1,23 +1,21 @@
doctype html
html
head
- link href='assets/application.css' media='screen' rel='stylesheet' type='text/css'
+ link href='#{{root_path}}assets/application.css' media='screen' rel='stylesheet' type='text/css'
title Sidekiq
body
- div class="navbar navbar-fixed-top"
- div class="navbar-inner"
- div class="container"
- a class='brand' href=''
+ .navbar.navbar-fixed-top
+ .navbar-inner
+ .container
+ a class='brand' href='#{{root_path}}'
| Sidekiq
ul class='nav'
li
- a href='' Home
-
- div class="container"
+ a href='#{{root_path}}' Home
+ li.pull-right
+ a Redis: #{location}
+ .container
== yield
- footer class="footer"
- p © #{Time.now.year} Mike Perham
-
- script type="text/javascript" src="assets/application.js"
+ script type="text/javascript" src="#{{root_path}}assets/application.js"
View
@@ -0,0 +1,11 @@
+header
+ h1 Latest messages in #{@name}
+
+table class="table table-striped table-bordered"
+ tr
+ th Class
+ th Arguments
+ - @messages.each do |msg|
+ tr
+ td= msg['class']
+ td= msg['args'].inspect[0..100]

0 comments on commit 0bfe2bd

Please sign in to comment.