Sha256: dbc87ed5cc943354ab0a2abab5c383457a20f04a48075e0b5aec58078cf7c51b

Contents?: true

Size: 988 Bytes

Versions: 1

Compression:

Stored size: 988 Bytes

Contents

require 'sidekiq/web'

module Sidetiq
  module Web

    def self.registered(app)
      app.helpers do
        def find_template(view, *args, &block)
          path = File.expand_path(File.join('..', 'views'), __FILE__)
          super(path, *args, &block)
          super
        end
      end

      app.get "/sidetiq" do
        clock = Sidetiq::Clock.instance
        @schedules = clock.schedules
        @time = clock.gettime
        slim :sidetiq
      end

      app.get "/sidetiq/:name" do
        halt 404 unless (name = params[:name])

        clock = Sidetiq::Clock.instance
        schedules = clock.schedules

        @time = clock.gettime

        @worker, @schedule = schedules.select do |worker, schedule|
          worker.name == name
        end.flatten

        slim :sidetiq_details
      end
    end
  end
end

Sidekiq::Web.register(Sidetiq::Web)

if Sidekiq::Web.tabs.is_a?(Array)
  Sidekiq::Web.tabs << "sidetiq"
else
  Sidekiq::Web.tabs["Sidetiq"] = "sidetiq"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidetiq-0.1.2 lib/sidetiq/web.rb