1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Adds a job status page for scheduled jobs; partially reverts 6ce788b121 which removed arg truncation from overview pages.

This commit is contained in:
Jonathan Hyman 2013-07-27 12:49:21 -04:00
parent 6ce788b121
commit 5e9bfa7ab7
9 changed files with 101 additions and 54 deletions

View file

@ -1,7 +1,7 @@
2.13.1
-----------
- Make summary bar and graphs responsive [manishval] [#1025]
- No longer truncates args in sidekiq-web, instead sets `overflow: scroll` [jonhyman]
- Adds a job status page for scheduled jobs [jonhyman]
2.13.0
-----------

View file

@ -10,6 +10,7 @@ If you're interested in helping or contributing to Sidekiq, here's
some known areas which need improvement:
* The Web UI and sidekiq.org website could always use more polish. If you have an eye for design and an idea for improvement, please open an issue and let us know.
* The config.ru file in this project has code you can use to populate the Web UI.
* The Sidekiq API has a serious issue: deleting elements and iterating
at the same time is broken, see #866, #1060.
* Make normal testing and inline testing dynamic: #1053

View file

@ -4,15 +4,24 @@ Sidekiq.configure_client do |config|
config.redis = { :size => 1 }
end
# Uncomment this to populate sidekiq-web with some fake data
#
#require 'multi_json'
#class TestDelayExtensionJob
# def self.test(*args)
# end
#end
#Sidekiq.redis {|conn| conn.flushdb }
#10.times do |idx|
#Sidekiq::Client.push('class' => 'HardWorker', 'args' => ['foo', 0.1, idx])
# Sidekiq::Client.push('class' => 'HardWorker', 'args' => ['foo', 0.1, idx])
# Sidekiq::Client.push('class' => 'HardWorker', 'args' => ['foo', 0.1, idx], 'at' => (Time.now + Random.rand(10000)).to_f)
# TestDelayExtensionJob.delay_for(1000).test("arg0")
#end
#
#Sidekiq.redis { |conn| conn.zadd('retry', Time.now.utc.to_f + 3000, MultiJson.encode({
#'class' => 'HardWorker', 'args' => ['foo', 0.1, Time.now.to_f],
#'queue' => 'default', 'error_message' => 'No such method', 'error_class' => 'NoMethodError',
#'failed_at' => Time.now.utc, 'retry_count' => 0 })) }
# 'class' => 'HardWorker', 'args' => ['foo', 0.1, Time.now.to_f],
# 'queue' => 'default', 'error_message' => 'No such method', 'error_class' => 'NoMethodError',
# 'failed_at' => Time.now.utc, 'retry_count' => 0 })) }
require 'sidekiq/web'
run Sidekiq::Web

View file

@ -107,9 +107,10 @@ module Sidekiq
[score.to_f, jid]
end
def display_args(args)
def display_args(args, truncate_after_chars = 2000)
args.map do |arg|
arg.inspect
a = arg.inspect
truncate_after_chars && a.size > truncate_after_chars ? "#{a[0..truncate_after_chars]}..." : a
end.join(", ")
end
@ -248,6 +249,13 @@ module Sidekiq
slim :scheduled
end
get "/scheduled/:key" do
halt 404 unless params['key']
@job = Sidekiq::ScheduledSet.new.fetch(*parse_params(params['key'])).first
redirect "#{root_path}scheduled" if @job.nil?
slim :scheduled_job_info
end
post '/scheduled' do
halt 404 unless params['key']
@ -262,6 +270,17 @@ module Sidekiq
redirect "#{root_path}scheduled"
end
post "/scheduled/:key" do
halt 404 unless params['key']
job = Sidekiq::ScheduledSet.new.fetch(*parse_params(params['key'])).first
if params['add_to_queue']
job.add_to_queue
elsif params['delete']
job.delete
end
redirect "#{root_path}scheduled"
end
get '/' do
@redis_info = Sidekiq.redis { |conn| conn.info }.select{ |k, v| redis_keys.include? k }
stats_history = Sidekiq::Stats::History.new((params[:days] || 30).to_i)

View file

@ -849,3 +849,7 @@ img.smallogo {
overflow: scroll;
max-height: 100px;
}
.args-extended {
overflow: scroll;
max-height: 500px;
}

51
web/views/_job_info.slim Normal file
View file

@ -0,0 +1,51 @@
header
h3 = t('Job')
table class="table table-bordered table-striped"
tbody
tr
th = t('Queue')
td
a href="#{root_path}queues/#{job['queue']}" #{job['queue']}
tr
th = t('Class')
td
code= job['class']
tr
th = t('Arguments')
td
code
// We don't want to truncate any job arguments when viewing a single job's status page
div.args-extended=display_args(job['args'], nil)
tr
th JID
td
code= job.jid
tr
th = t('Enqueued')
td== relative_time(job.enqueued_at)
- unless retry_extra_items(job).empty?
tr
th = t('Extras')
td
code
= retry_extra_items(job).inspect
- if type == :retry
- if job['retry_count'] && job['retry_count'] > 0
tr
th = t('RetryCount')
td= job['retry_count']
tr
th = t('LastRetry')
td== relative_time(job['retried_at'].is_a?(Numeric) ? Time.at(job['retried_at']) : Time.parse(job['retried_at']))
- else
tr
th = t('OriginallyFailed')
td== relative_time(job['failed_at'].is_a?(Numeric) ? Time.at(job['failed_at']) : Time.parse(job['failed_at']))
tr
th = t('NextRetry')
td== relative_time(job.at)
- if type == :scheduled
tr
th = t('Scheduled')
td== relative_time(job.at)

View file

@ -1,48 +1,4 @@
header
h3 = t('Job')
table class="retry table table-bordered table-striped"
tbody
tr
th = t('Queue')
td
a href="#{root_path}queues/#{@retry['queue']}" #{@retry['queue']}
tr
th = t('Class')
td
code= @retry['class']
tr
th = t('Arguments')
td
code
div.args=display_args(@retry['args'])
tr
th JID
td
code= @retry.jid
tr
th = t('Enqueued')
td== relative_time(@retry.enqueued_at)
- unless retry_extra_items(@retry).empty?
tr
th = t('Extras')
td
code
= retry_extra_items(@retry).inspect
- if @retry['retry_count'] > 0
tr
th = t('RetryCount')
td= @retry['retry_count']
tr
th = t('LastRetry')
td== relative_time(@retry['retried_at'].is_a?(Numeric) ? Time.at(@retry['retried_at']) : Time.parse(@retry['retried_at']))
- else
tr
th = t('OriginallyFailed')
td== relative_time(@retry['failed_at'].is_a?(Numeric) ? Time.at(@retry['failed_at']) : Time.parse(@retry['failed_at']))
tr
th = t('NextRetry')
td== relative_time(@retry.at)
== slim :_job_info, :locals => {:job => @retry, :type => :retry}
h3 = t('Error')
table class="error table table-bordered table-striped"

View file

@ -20,7 +20,8 @@ header.row
tr
td
input type='checkbox' name='key[]' value='#{job_params(msg, score)}'
td== relative_time(Time.at(score))
td
a href="#{root_path}scheduled/#{job_params(msg, score)}"== relative_time(Time.at(score))
td
a href="#{root_path}queues/#{msg['queue']}" #{msg['queue']}
td= msg['class']

View file

@ -0,0 +1,6 @@
== slim :_job_info, :locals => {:job => @job, :type => :scheduled}
form.form-horizontal action="#{root_path}scheduled/#{job_params(@job, @job.score)}" method="post"
a.btn href="#{root_path}scheduled" = t('GoBack')
input.btn.btn-primary type="submit" name="add_to_queue" value="#{t('AddToQueue')}"
input.btn.btn-danger type="submit" name="delete" value="#{t('Delete')}"