Sha256: 4648fbb7189596f8cc1268a73a91c284e2447482ac6609b8c02972414baf5fa5
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
require 'sidekiq/web' module Sidetiq module Web VIEWS = File.expand_path('views', File.dirname(__FILE__)) def self.registered(app) app.get "/sidetiq" do @schedules = Sidetiq.schedules @time = Sidetiq.clock.gettime erb File.read(File.join(VIEWS, 'sidetiq.erb')) end app.get "/sidetiq/locks" do @locks = Sidetiq::Lock::Redis.all.map(&:meta_data) erb File.read(File.join(VIEWS, 'locks.erb')) end app.get "/sidetiq/:name/schedule" do halt 404 unless (name = params[:name]) @time = Sidetiq.clock.gettime @worker, @schedule = Sidetiq.schedules.select do |worker, _| worker.name == name end.flatten erb File.read(File.join(VIEWS, 'schedule.erb')) end app.get "/sidetiq/:name/history" do halt 404 unless (name = params[:name]) @time = Sidetiq.clock.gettime @worker, @schedule = Sidetiq.schedules.select do |worker, _| worker.name == name end.flatten @history = Sidekiq.redis do |redis| redis.lrange("sidetiq:#{@worker.name}:history", 0, -1) end erb File.read(File.join(VIEWS, 'history.erb')) end app.post "/sidetiq/:name/trigger" do halt 404 unless (name = params[:name]) worker, _ = Sidetiq.schedules.select do |w, _| w.name == name end.flatten worker.perform_async redirect "#{root_path}sidetiq" end app.post "/sidetiq/:name/unlock" do halt 404 unless (name = params[:name]) Sidetiq::Lock::Redis.new(name).unlock! redirect "#{root_path}sidetiq/locks" end end end end Sidekiq::Web.register(Sidetiq::Web) Sidekiq::Web.tabs["Sidetiq"] = "sidetiq"
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sidetiq-0.4.0.rc2 | lib/sidetiq/web.rb |
sidetiq-0.4.0.rc1 | lib/sidetiq/web.rb |