-
-
Save mickey/f3a8d0b2593b995c1f94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<% if ClockworkWeb.redis %> | |
<% if ClockworkWeb.monitor %> | |
<% if ClockworkWeb.multiple? %> | |
<p>Multiple clockwork processes detected</p> | |
<% elsif ClockworkWeb.running? %> | |
<p>Clockwork is running</p> | |
<% else %> | |
<p> | |
Clockwork is not running | |
<% if @last_heartbeat %> | |
- last heartbeat was <%= time_ago_in_words(@last_heartbeat) %> ago | |
<% end %> | |
</p> | |
<% end %> | |
<% end %> | |
<% else %> | |
<p>Add Redis for monitoring and disabling jobs</p> | |
<% end %> | |
<div class="table_container"> | |
<table class="queues table table-hover table-bordered table-striped table-white"> | |
<thead> | |
<tr> | |
<th>Job</th> | |
<th style="width: 20%;">Period</th> | |
<th style="width: 20%;">Last Run</th> | |
</tr> | |
</thead> | |
<tbody> | |
<% @events.each do |event| %> | |
<% enabled = !@disabled.include?(event.job) %> | |
<tr class="<%= enabled ? "" : "disabled" %>"> | |
<td><%= event.job %></td> | |
<td> | |
<%= friendly_period(event.instance_variable_get(:@period)) %> | |
<% at = event.instance_variable_get(:@at) %> | |
<% if at %> | |
at <%= friendly_time_part(at.instance_variable_get(:@hour)) %>:<%= friendly_time_part(at.instance_variable_get(:@min)) %> | |
<% end %> | |
<% if event.instance_variable_get(:@if) %> | |
if __ | |
<% end %> | |
</td> | |
<td><%= last_run(@last_runs[event.job]) %></td> | |
</tr> | |
<% end %> | |
</tbody> | |
</table> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sidekiq | |
module Clockwork | |
module WebExtension | |
def self.registered(app) | |
view_path = File.expand_path("app/views/sidekiq") | |
app.helpers ActionView::Helpers::TextHelper, | |
ActionView::Helpers::DateHelper, | |
ClockworkWeb::HomeHelper | |
app.get "/schedules" do | |
@events = | |
::Clockwork.manager.instance_variable_get(:@events).sort_by do |e| | |
at = e.instance_variable_get(:@at) | |
[ | |
e.instance_variable_get(:@period), | |
(at && at.instance_variable_get(:@hour)) || -1, | |
(at && at.instance_variable_get(:@min)) || -1, | |
e.job.to_s | |
] | |
end | |
@last_runs = ClockworkWeb.last_runs | |
@disabled = ClockworkWeb.disabled_jobs | |
@last_heartbeat = ClockworkWeb.last_heartbeat | |
render :erb, File.read(File.join(view_path, "schedules.html.erb")) | |
end | |
end | |
end | |
end | |
end | |
Sidekiq::Web.register Sidekiq::Clockwork::WebExtension | |
Sidekiq::Web.tabs["Scheduled Tasks"] = "schedules" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment