lib/sidetiq/web.rb in sidetiq-0.6.0 vs lib/sidetiq/web.rb in sidetiq-0.6.1
- old
+ new
@@ -1,5 +1,6 @@
+require 'sidetiq'
require 'sidekiq/web'
module Sidetiq
module Web
VIEWS = File.expand_path('views', File.dirname(__FILE__))
@@ -52,10 +53,23 @@
worker = Sidetiq.workers.detect do |worker|
worker.name == name
end
- worker.perform_async
+ case worker.instance_method(:perform).arity.abs
+ when 0
+ worker.perform_async
+ when 1
+ Sidekiq.redis do |redis|
+ last_run = (redis.get("sidetiq:#{worker.name}:last") || -1).to_f
+ worker.perform_async(last_run)
+ end
+ else
+ Sidekiq.redis do |redis|
+ last_run = (redis.get("sidetiq:#{worker.name}:last") || -1).to_f
+ worker.perform_async(last_run, Sidetiq.clock.gettime.to_i)
+ end
+ end
redirect "#{root_path}sidetiq"
end
app.post "/sidetiq/:name/unlock" do