lib/resque/server.rb in resque-1.15.0 vs lib/resque/server.rb in resque-1.16.0
- old
+ new
@@ -1,9 +1,10 @@
require 'sinatra/base'
require 'erb'
require 'resque'
require 'resque/version'
+require 'time'
module Resque
class Server < Sinatra::Base
dir = File.dirname(File.expand_path(__FILE__))
@@ -122,15 +123,31 @@
erb page.to_sym, {:layout => layout}, :resque => Resque
rescue Errno::ECONNREFUSED
erb :error, {:layout => false}, :error => "Can't connect to Redis! (#{Resque.redis_id})"
end
end
+
+ def show_for_polling(page)
+ content_type "text/html"
+ @polling = true
+ show(page.to_sym, false).gsub(/\s{1,}/, ' ')
+ end
# to make things easier on ourselves
get "/?" do
redirect url_path(:overview)
end
+
+ %w( overview workers ).each do |page|
+ get "/#{page}.poll" do
+ show_for_polling(page)
+ end
+
+ get "/#{page}/:id.poll" do
+ show_for_polling(page)
+ end
+ end
%w( overview queues working workers key ).each do |page|
get "/#{page}" do
show page
end
@@ -141,17 +158,9 @@
end
post "/queues/:id/remove" do
Resque.remove_queue(params[:id])
redirect u('queues')
- end
-
- %w( overview workers ).each do |page|
- get "/#{page}.poll" do
- content_type "text/html"
- @polling = true
- show(page.to_sym, false).gsub(/\s{1,}/, ' ')
- end
end
get "/failed" do
if Resque::Failure.url
redirect Resque::Failure.url