mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Implement simple home page and queue page
This commit is contained in:
parent
20e51f1276
commit
0bfe2bd416
6 changed files with 79 additions and 18 deletions
8
config.ru
Normal file
8
config.ru
Normal file
|
@ -0,0 +1,8 @@
|
|||
require 'sidekiq'
|
||||
|
||||
Sidekiq.configure_client do |config|
|
||||
config.redis = { :size => 1 }
|
||||
end
|
||||
|
||||
require 'sidekiq/web'
|
||||
run Sidekiq::Web
|
|
@ -32,11 +32,33 @@ module Sidekiq
|
|||
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
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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"
|
||||
|
|
11
web/views/queue.slim
Normal file
11
web/views/queue.slim
Normal file
|
@ -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]
|
Loading…
Reference in a new issue