sidekiq-cron 1.12.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -2
- data/Gemfile +3 -0
- data/README.md +256 -36
- data/lib/sidekiq/cron/job.rb +262 -168
- data/lib/sidekiq/cron/launcher.rb +2 -5
- data/lib/sidekiq/cron/locales/de.yml +15 -6
- data/lib/sidekiq/cron/locales/en.yml +14 -14
- data/lib/sidekiq/cron/locales/es.yml +22 -0
- data/lib/sidekiq/cron/locales/id.yml +22 -0
- data/lib/sidekiq/cron/locales/it.yml +15 -16
- data/lib/sidekiq/cron/locales/ja.yml +14 -10
- data/lib/sidekiq/cron/locales/pt.yml +14 -14
- data/lib/sidekiq/cron/locales/ru.yml +15 -7
- data/lib/sidekiq/cron/locales/zh-CN.yml +14 -11
- data/lib/sidekiq/cron/namespace.rb +48 -0
- data/lib/sidekiq/cron/poller.rb +12 -13
- data/lib/sidekiq/cron/schedule_loader.rb +51 -15
- data/lib/sidekiq/cron/support.rb +4 -30
- data/lib/sidekiq/cron/version.rb +1 -1
- data/lib/sidekiq/cron/views/cron.erb +96 -91
- data/lib/sidekiq/cron/views/cron_show.erb +87 -82
- data/lib/sidekiq/cron/views/legacy/cron.erb +113 -0
- data/lib/sidekiq/cron/views/legacy/cron_show.erb +92 -0
- data/lib/sidekiq/cron/web.rb +21 -2
- data/lib/sidekiq/cron/web_extension.rb +95 -31
- data/lib/sidekiq/cron.rb +73 -5
- data/lib/sidekiq/options.rb +3 -5
- data/lib/sidekiq-cron.rb +6 -0
- data/sidekiq-cron.gemspec +5 -4
- metadata +38 -13
@@ -1,98 +1,103 @@
|
|
1
|
-
<
|
2
|
-
<
|
3
|
-
<
|
4
|
-
|
5
|
-
|
1
|
+
<section>
|
2
|
+
<header>
|
3
|
+
<h2>
|
4
|
+
<%= t('CronJobs') %>
|
5
|
+
<small>(<%= @current_namespace %>)</small>
|
6
|
+
</h2>
|
6
7
|
<% if @cron_jobs.size > 0 %>
|
7
|
-
<form
|
8
|
-
<%=
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
<%=
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<%=
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
<%=
|
21
|
-
|
8
|
+
<form class="filter">
|
9
|
+
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/delete" method="post">
|
10
|
+
<%= csrf_tag %>
|
11
|
+
<input class="btn btn-danger" type="submit" name="delete" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSureDeleteCronJobs') %>" />
|
12
|
+
</form>
|
13
|
+
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/disable" method="post">
|
14
|
+
<%= csrf_tag %>
|
15
|
+
<input class="btn btn-primary" type="submit" name="enqueue" value="<%= t('DisableAll') %>" />
|
16
|
+
</form>
|
17
|
+
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/enable" method="post">
|
18
|
+
<%= csrf_tag %>
|
19
|
+
<input class="btn btn-primary" type="submit" name="enqueue" value="<%= t('EnableAll') %>" />
|
20
|
+
</form>
|
21
|
+
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/enqueue" method="post">
|
22
|
+
<%= csrf_tag %>
|
23
|
+
<input class="btn btn-primary" type="submit" name="enqueue" value="<%= t('EnqueueAll') %>" data-confirm="<%= t('AreYouSureEnqueueCronJobs') %>" />
|
24
|
+
</form>
|
22
25
|
</form>
|
23
26
|
<% end %>
|
27
|
+
</header>
|
28
|
+
<!-- Namespaces -->
|
29
|
+
<div class="cards-container">
|
30
|
+
<% Sidekiq::Cron::Namespace.all_with_count.sort_by { |namespace| namespace[:name] }.each do |namespace| %>
|
31
|
+
<article>
|
32
|
+
<a href="<%= root_path %>cron/namespaces/<%= namespace[:name] %>">
|
33
|
+
<span class="count"><%= namespace[:count] %></span>
|
34
|
+
<span class="desc"><%= namespace[:name] %></span>
|
35
|
+
</a>
|
36
|
+
</article>
|
37
|
+
<% end %>
|
24
38
|
</div>
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
<table class="table table-hover table-bordered table-striped table-white">
|
30
|
-
<thead>
|
31
|
-
<th><%= t('Status') %></th>
|
32
|
-
<th><%= t('Name') %></th>
|
33
|
-
<th><%= t('Cron string') %></th>
|
34
|
-
<th><%= t('Last enqueued') %></th>
|
35
|
-
<th width="180"><%= t('Actions')%></th>
|
36
|
-
</thead>
|
37
|
-
|
38
|
-
<tbody>
|
39
|
-
<% @cron_jobs.sort{|a,b| a.sort_name <=> b.sort_name }.each_with_index do |job, index| %>
|
40
|
-
<% style = "#{job.status == 'disabled' ? "background: #ecc; color: #585454;": ""}" %>
|
39
|
+
<!-- Namespaces -->
|
40
|
+
<% if @cron_jobs.size > 0 %>
|
41
|
+
<table class="table table-hover table-bordered table-striped table-white">
|
42
|
+
<thead>
|
41
43
|
<tr>
|
42
|
-
<
|
43
|
-
<
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
<th><%= t('Status') %></th>
|
45
|
+
<th width="50%"><%= t('Name') %></th>
|
46
|
+
<th><%= t('CronString') %></th>
|
47
|
+
<th><%= t('LastEnqueued') %></th>
|
48
|
+
<th width="180"><%= t('Actions') %></th>
|
49
|
+
</tr>
|
50
|
+
</thead>
|
51
|
+
<tbody>
|
52
|
+
<% @cron_jobs.sort{ |a,b| a.sort_name <=> b.sort_name }.each do |job| %>
|
53
|
+
<% klass = (job.status == 'disabled') ? 'bg-danger text-muted' : '' %>
|
54
|
+
<% escaped_job_name = CGI.escape(job.name).gsub('+', '%20') %>
|
55
|
+
<tr>
|
56
|
+
<td class="<%= klass %>"><%= t job.status %></td>
|
57
|
+
<td class="<%= klass %>">
|
58
|
+
<a href="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>" title="<%= job.description %>">
|
59
|
+
<b class="<%= klass %>"><%= job.name %></b>
|
60
|
+
</a>
|
61
|
+
<br/>
|
62
|
+
<% if job.message and job.message.to_s.size > 100 %>
|
63
|
+
<details>
|
64
|
+
<p><small><%= job.message %></small></p>
|
65
|
+
</details>
|
54
66
|
<% else %>
|
55
|
-
<
|
56
|
-
<div class="toggle worker_<%= index %>" style="display: inline;"><%= job.message[0..100] + "... " %></div>
|
57
|
-
<div class="toggle worker_<%= index %>" style="display: none;"><%= job.message %></div>
|
67
|
+
<small><%= job.message %></small>
|
58
68
|
<% end %>
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
</
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
</table>
|
95
|
-
<% else %>
|
96
|
-
<div class='alert alert-success'><%= t('NoCronJobsWereFound') %></div>
|
97
|
-
<% end %>
|
98
|
-
|
69
|
+
</td>
|
70
|
+
<td class="<%= klass %>"><b><%= job.human_cron %><br/>
|
71
|
+
<small><%= job.cron.gsub(" ", " ") %></small></b></td>
|
72
|
+
<td class="<%= klass %>"><%= job.last_enqueue_time ? relative_time(job.last_enqueue_time) : "-" %></td>
|
73
|
+
<td class="<%= klass %>">
|
74
|
+
<div class="pagination" style="padding: 0px">
|
75
|
+
<form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/enqueue" method="post">
|
76
|
+
<%= csrf_tag %>
|
77
|
+
<input class='btn btn-warn' type="submit" name="enqueue" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => job.name) %>"/>
|
78
|
+
</form>
|
79
|
+
<% if job.status == 'enabled' %>
|
80
|
+
<form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/disable" method="post">
|
81
|
+
<%= csrf_tag %>
|
82
|
+
<input class='btn btn-warn' type="submit" name="disable" value="<%= t('Disable') %>"/>
|
83
|
+
</form>
|
84
|
+
<% else %>
|
85
|
+
<form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/enable" method="post">
|
86
|
+
<%= csrf_tag %>
|
87
|
+
<input class='btn btn-warn' type="submit" name="enable" value="<%= t('Enable') %>"/>
|
88
|
+
</form>
|
89
|
+
<form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/delete" method="post">
|
90
|
+
<%= csrf_tag %>
|
91
|
+
<input class='btn btn-danger' type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteCronJob', :job => job.name) %>"/>
|
92
|
+
</form>
|
93
|
+
<% end %>
|
94
|
+
</div>
|
95
|
+
</td>
|
96
|
+
</tr>
|
97
|
+
<% end %>
|
98
|
+
</tbody>
|
99
|
+
</table>
|
100
|
+
<% else %>
|
101
|
+
<div class='alert alert-success'><%= t('NoCronJobsWereFound') %></div>
|
102
|
+
<% end %>
|
103
|
+
</section>
|
@@ -1,88 +1,93 @@
|
|
1
|
-
<
|
2
|
-
<
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<%=
|
12
|
-
|
13
|
-
|
14
|
-
<% if @job.status == 'enabled' %>
|
15
|
-
<form action="<%= cron_job_path %>/disable?redirect=<%= cron_job_path %>" method="post">
|
16
|
-
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
17
|
-
<input class="btn btn-warn pull-left" name="disable" type="submit" value="<%= t('Disable') %>" />
|
18
|
-
</form>
|
19
|
-
<% else %>
|
20
|
-
<form action="<%= cron_job_path %>/enable?redirect=<%= cron_job_path %>" method="post">
|
21
|
-
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
22
|
-
<input class="btn btn-warn pull-left" name="enable" type="submit" value="<%= t('Enable') %>" />
|
1
|
+
<section>
|
2
|
+
<header>
|
3
|
+
<div>
|
4
|
+
<h2>
|
5
|
+
<%= "#{t('Cron')} #{t('Job')}" %>
|
6
|
+
<small><%= @job.name %></small>
|
7
|
+
</h2>
|
8
|
+
</div>
|
9
|
+
<form class="filter">
|
10
|
+
<% cron_job_path = "#{root_path}cron/namespaces/#{@current_namespace}/jobs/#{CGI.escape(@job.name).gsub('+', '%20')}" %>
|
11
|
+
<form action="<%= cron_job_path %>/enqueue?redirect=<%= cron_job_path %>" method="post">
|
12
|
+
<%= csrf_tag %>
|
13
|
+
<input class="btn btn-primary" name="enqueue" type="submit" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => @job.name) %>" />
|
23
14
|
</form>
|
24
|
-
|
25
|
-
<%=
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
<
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
<tr>
|
43
|
-
<th><%= t 'Description' %></th>
|
44
|
-
<td><%= @job.description %></td>
|
45
|
-
</tr>
|
46
|
-
<tr>
|
47
|
-
<th><%= t 'Message' %></th>
|
48
|
-
<td><pre><%= @job.pretty_message %></pre></td>
|
49
|
-
</tr>
|
50
|
-
<tr>
|
51
|
-
<th><%= t 'Cron' %></th>
|
52
|
-
<td><%= @job.cron.gsub(" ", " ") %></td>
|
53
|
-
</tr>
|
54
|
-
<tr>
|
55
|
-
<th><%= t 'Last enqueued' %></th>
|
56
|
-
<td><%= @job.last_enqueue_time ? relative_time(@job.last_enqueue_time) : "-" %></td>
|
57
|
-
</tr>
|
58
|
-
</tbody>
|
59
|
-
</table>
|
60
|
-
|
61
|
-
<header class="row">
|
62
|
-
<div class="col-sm-12">
|
63
|
-
<h4>
|
64
|
-
<%= t 'History' %>
|
65
|
-
</h4>
|
66
|
-
</div>
|
67
|
-
</header>
|
68
|
-
|
69
|
-
<% if @job.jid_history_from_redis.size > 0 %>
|
70
|
-
<table class="table table-hover table-bordered table-striped">
|
71
|
-
<thead>
|
72
|
-
<tr>
|
73
|
-
<th><%= t 'Enqueued' %></th>
|
74
|
-
<th><%= t 'JID' %></th>
|
75
|
-
</tr>
|
76
|
-
</thead>
|
15
|
+
<% if @job.status == 'enabled' %>
|
16
|
+
<form action="<%= cron_job_path %>/disable?redirect=<%= cron_job_path %>" method="post">
|
17
|
+
<%= csrf_tag %>
|
18
|
+
<input class="btn btn-primary" name="disable" type="submit" value="<%= t('Disable') %>" />
|
19
|
+
</form>
|
20
|
+
<% else %>
|
21
|
+
<form action="<%= cron_job_path %>/enable?redirect=<%= cron_job_path %>" method="post">
|
22
|
+
<%= csrf_tag %>
|
23
|
+
<input class="btn btn-primary" name="enable" type="submit" value="<%= t('Enable') %>" />
|
24
|
+
</form>
|
25
|
+
<form action="<%= cron_job_path %>/delete" method="post">
|
26
|
+
<%= csrf_tag %>
|
27
|
+
<input class="btn btn-danger" data-confirm="<%= t('AreYouSureDeleteCronJob', :job => @job.name) %>" name="delete" type="submit" value="<%= t('Delete') %>" />
|
28
|
+
</form>
|
29
|
+
<% end %>
|
30
|
+
</form>
|
31
|
+
</header>
|
32
|
+
<table class="table table-bordered table-striped">
|
77
33
|
<tbody>
|
78
|
-
<% @job.jid_history_from_redis.each do |jid_history| %>
|
79
34
|
<tr>
|
80
|
-
<
|
81
|
-
<td><%=
|
35
|
+
<th><%= t 'Status' %></th>
|
36
|
+
<td><%= @job.status %></td>
|
37
|
+
</tr>
|
38
|
+
<tr>
|
39
|
+
<th><%= t 'Name' %></th>
|
40
|
+
<td><%= @job.name %></td>
|
41
|
+
</tr>
|
42
|
+
<tr>
|
43
|
+
<th><%= t 'Namespace' %></th>
|
44
|
+
<td><%= @job.namespace %></td>
|
45
|
+
</tr>
|
46
|
+
<tr>
|
47
|
+
<th><%= t 'Description' %></th>
|
48
|
+
<td><%= @job.description %></td>
|
49
|
+
</tr>
|
50
|
+
<tr>
|
51
|
+
<th><%= t 'Message' %></th>
|
52
|
+
<td>
|
53
|
+
<pre><%= @job.pretty_message %></pre>
|
54
|
+
</td>
|
55
|
+
</tr>
|
56
|
+
<tr>
|
57
|
+
<th><%= t 'Cron' %></th>
|
58
|
+
<td><%= @job.cron.gsub(" ", " ") %></td>
|
59
|
+
</tr>
|
60
|
+
<tr>
|
61
|
+
<th><%= t 'Last enqueued' %></th>
|
62
|
+
<td><%= @job.last_enqueue_time ? relative_time(@job.last_enqueue_time) : "-" %></td>
|
82
63
|
</tr>
|
83
|
-
<% end %>
|
84
64
|
</tbody>
|
85
65
|
</table>
|
86
|
-
|
87
|
-
|
88
|
-
|
66
|
+
<header>
|
67
|
+
<div>
|
68
|
+
<h4>
|
69
|
+
<%= t 'History' %>
|
70
|
+
</h4>
|
71
|
+
</div>
|
72
|
+
</header>
|
73
|
+
<% if @job.jid_history_from_redis.size > 0 %>
|
74
|
+
<table class="table table-hover table-bordered table-striped">
|
75
|
+
<thead>
|
76
|
+
<tr>
|
77
|
+
<th><%= t 'Enqueued' %></th>
|
78
|
+
<th><%= t 'JID' %></th>
|
79
|
+
</tr>
|
80
|
+
</thead>
|
81
|
+
<tbody>
|
82
|
+
<% @job.jid_history_from_redis.each do |jid_history| %>
|
83
|
+
<tr>
|
84
|
+
<td><%= jid_history['enqueued'] %></td>
|
85
|
+
<td><%= jid_history['jid'] %></td>
|
86
|
+
</tr>
|
87
|
+
<% end %>
|
88
|
+
</tbody>
|
89
|
+
</table>
|
90
|
+
<% else %>
|
91
|
+
<div class='alert alert-success'><%= t 'NoHistoryWereFound' %></div>
|
92
|
+
<% end %>
|
93
|
+
</section>
|
@@ -0,0 +1,113 @@
|
|
1
|
+
<header class='row'>
|
2
|
+
<div class='col-sm-5 pull-left'>
|
3
|
+
<h3>
|
4
|
+
<%= t('CronJobs') %>
|
5
|
+
<small><%= @current_namespace %></small>
|
6
|
+
</h3>
|
7
|
+
</div>
|
8
|
+
<div class='col-sm-7 pull-right h2'>
|
9
|
+
<% if @cron_jobs.size > 0 %>
|
10
|
+
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/delete" method="post" class="pull-right">
|
11
|
+
<%= csrf_tag %>
|
12
|
+
<input class="btn btn-danger" type="submit" name="delete" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSureDeleteCronJobs') %>" />
|
13
|
+
</form>
|
14
|
+
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/disable" method="post" class="pull-right">
|
15
|
+
<%= csrf_tag %>
|
16
|
+
<input class="btn btn-warn" type="submit" name="enqueue" value="<%= t('DisableAll') %>" />
|
17
|
+
</form>
|
18
|
+
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/enable" method="post" class="pull-right">
|
19
|
+
<%= csrf_tag %>
|
20
|
+
<input class="btn btn-warn" type="submit" name="enqueue" value="<%= t('EnableAll') %>" />
|
21
|
+
</form>
|
22
|
+
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/enqueue" method="post" class="pull-right">
|
23
|
+
<%= csrf_tag %>
|
24
|
+
<input class="btn btn-warn" type="submit" name="enqueue" value="<%= t('EnqueueAll') %>" data-confirm="<%= t('AreYouSureEnqueueCronJobs') %>" />
|
25
|
+
</form>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
28
|
+
</header>
|
29
|
+
|
30
|
+
<!-- Namespaces -->
|
31
|
+
<div class='row'>
|
32
|
+
<div class="col-sm-12 summary_bar">
|
33
|
+
<ul class="list-unstyled summary row">
|
34
|
+
<% Sidekiq::Cron::Namespace.all_with_count.sort_by { |namespace| namespace[:name] }.each do |namespace| %>
|
35
|
+
<li class="col-sm-1">
|
36
|
+
<a href="<%= root_path %>cron/namespaces/<%= namespace[:name] %>">
|
37
|
+
<span class="count"><%= namespace[:count] %></span>
|
38
|
+
<span class="desc"><%= namespace[:name] %></span>
|
39
|
+
</a>
|
40
|
+
</li>
|
41
|
+
<% end %>
|
42
|
+
</ul>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
<!-- Namespaces -->
|
46
|
+
|
47
|
+
<% if @cron_jobs.size > 0 %>
|
48
|
+
<table class="table table-hover table-bordered table-striped table-white">
|
49
|
+
<thead>
|
50
|
+
<tr>
|
51
|
+
<th><%= t('Status') %></th>
|
52
|
+
<th width="50%"><%= t('Name') %></th>
|
53
|
+
<th><%= t('CronString') %></th>
|
54
|
+
<th><%= t('LastEnqueued') %></th>
|
55
|
+
<th width="180"><%= t('Actions') %></th>
|
56
|
+
</tr>
|
57
|
+
</thead>
|
58
|
+
|
59
|
+
<tbody>
|
60
|
+
<% @cron_jobs.sort{ |a,b| a.sort_name <=> b.sort_name }.each do |job| %>
|
61
|
+
<% klass = (job.status == 'disabled') ? 'bg-danger text-muted' : '' %>
|
62
|
+
<% escaped_job_name = CGI.escape(job.name).gsub('+', '%20') %>
|
63
|
+
<tr>
|
64
|
+
<td class="<%= klass %>"><%= t job.status %></td>
|
65
|
+
<td class="<%= klass %>">
|
66
|
+
<a href="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>" title="<%= job.description %>">
|
67
|
+
<b class="<%= klass %>"><%= job.name %></b>
|
68
|
+
</a>
|
69
|
+
<br/>
|
70
|
+
<% if job.message and job.message.to_s.size > 100 %>
|
71
|
+
<details>
|
72
|
+
<summary class="btn btn-warn btn-xs">Show message</summary>
|
73
|
+
<p><small><%= job.message %></small></p>
|
74
|
+
</details>
|
75
|
+
<% else %>
|
76
|
+
<small><%= job.message %></small>
|
77
|
+
<% end %>
|
78
|
+
</td>
|
79
|
+
<td class="<%= klass %>"><b><%= job.human_cron %><br/><small><%= job.cron_expression_string.gsub(" ", " ") %></small></b></td>
|
80
|
+
<td class="<%= klass %>"><%= job.last_enqueue_time ? relative_time(job.last_enqueue_time) : "-" %></td>
|
81
|
+
<td class="<%= klass %>">
|
82
|
+
<% if job.status == 'enabled' %>
|
83
|
+
<form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/enqueue" method="post">
|
84
|
+
<%= csrf_tag %>
|
85
|
+
<input class='btn btn-warn btn-xs pull-left' type="submit" name="enqueue" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => job.name) %>"/>
|
86
|
+
</form>
|
87
|
+
<form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/disable" method="post">
|
88
|
+
<%= csrf_tag %>
|
89
|
+
<input class='btn btn-warn btn-xs pull-left' type="submit" name="disable" value="<%= t('Disable') %>"/>
|
90
|
+
</form>
|
91
|
+
<% else %>
|
92
|
+
<form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/enqueue" method="post">
|
93
|
+
<%= csrf_tag %>
|
94
|
+
<input class='btn btn-warn btn-xs pull-left' type="submit" name="enqueue" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => job.name) %>"/>
|
95
|
+
</form>
|
96
|
+
<form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/enable" method="post">
|
97
|
+
<%= csrf_tag %>
|
98
|
+
<input class='btn btn-warn btn-xs pull-left' type="submit" name="enable" value="<%= t('Enable') %>"/>
|
99
|
+
</form>
|
100
|
+
<form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/delete" method="post">
|
101
|
+
<%= csrf_tag %>
|
102
|
+
<input class='btn btn-xs btn-danger pull-left help-block' type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteCronJob', :job => job.name) %>"/>
|
103
|
+
</form>
|
104
|
+
<% end %>
|
105
|
+
</td>
|
106
|
+
</tr>
|
107
|
+
<% end %>
|
108
|
+
</tbody>
|
109
|
+
</table>
|
110
|
+
<% else %>
|
111
|
+
<div class='alert alert-success'><%= t('NoCronJobsWereFound') %></div>
|
112
|
+
<% end %>
|
113
|
+
|
@@ -0,0 +1,92 @@
|
|
1
|
+
<header class="row">
|
2
|
+
<div class="span col-sm-5 pull-left">
|
3
|
+
<h3>
|
4
|
+
<%= "#{t('Cron')} #{t('Job')}" %>
|
5
|
+
<small><%= @job.name %></small>
|
6
|
+
</h3>
|
7
|
+
</div>
|
8
|
+
<div class="span col-sm-7 pull-right h2">
|
9
|
+
<% cron_job_path = "#{root_path}cron/namespaces/#{@current_namespace}/jobs/#{CGI.escape(@job.name).gsub('+', '%20')}" %>
|
10
|
+
<form action="<%= cron_job_path %>/enqueue?redirect=<%= cron_job_path %>" class="pull-right" method="post">
|
11
|
+
<%= csrf_tag %>
|
12
|
+
<input class="btn btn-warn pull-left" name="enqueue" type="submit" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => @job.name) %>" />
|
13
|
+
</form>
|
14
|
+
<% if @job.status == 'enabled' %>
|
15
|
+
<form action="<%= cron_job_path %>/disable?redirect=<%= cron_job_path %>" class="pull-right" method="post">
|
16
|
+
<%= csrf_tag %>
|
17
|
+
<input class="btn btn-warn pull-left" name="disable" type="submit" value="<%= t('Disable') %>" />
|
18
|
+
</form>
|
19
|
+
<% else %>
|
20
|
+
<form action="<%= cron_job_path %>/enable?redirect=<%= cron_job_path %>" class="pull-right" method="post">
|
21
|
+
<%= csrf_tag %>
|
22
|
+
<input class="btn btn-warn pull-left" name="enable" type="submit" value="<%= t('Enable') %>" />
|
23
|
+
</form>
|
24
|
+
<form action="<%= cron_job_path %>/delete" class="pull-right" method="post">
|
25
|
+
<%= csrf_tag %>
|
26
|
+
<input class="btn btn-danger pull-left" data-confirm="<%= t('AreYouSureDeleteCronJob', :job => @job.name) %>" name="delete" type="submit" value="<%= t('Delete') %>" />
|
27
|
+
</form>
|
28
|
+
<% end %>
|
29
|
+
</div>
|
30
|
+
</header>
|
31
|
+
|
32
|
+
<table class="table table-bordered table-striped">
|
33
|
+
<tbody>
|
34
|
+
<tr>
|
35
|
+
<th><%= t 'Status' %></th>
|
36
|
+
<td><%= @job.status %></td>
|
37
|
+
</tr>
|
38
|
+
<tr>
|
39
|
+
<th><%= t 'Name' %></th>
|
40
|
+
<td><%= @job.name %></td>
|
41
|
+
</tr>
|
42
|
+
<tr>
|
43
|
+
<th><%= t 'Namespace' %></th>
|
44
|
+
<td><%= @job.namespace %></td>
|
45
|
+
</tr>
|
46
|
+
<tr>
|
47
|
+
<th><%= t 'Description' %></th>
|
48
|
+
<td><%= @job.description %></td>
|
49
|
+
</tr>
|
50
|
+
<tr>
|
51
|
+
<th><%= t 'Message' %></th>
|
52
|
+
<td><pre><%= @job.pretty_message %></pre></td>
|
53
|
+
</tr>
|
54
|
+
<tr>
|
55
|
+
<th><%= t 'Cron' %></th>
|
56
|
+
<td><%= @job.cron.gsub(" ", " ") %></td>
|
57
|
+
</tr>
|
58
|
+
<tr>
|
59
|
+
<th><%= t 'Last enqueued' %></th>
|
60
|
+
<td><%= @job.last_enqueue_time ? relative_time(@job.last_enqueue_time) : "-" %></td>
|
61
|
+
</tr>
|
62
|
+
</tbody>
|
63
|
+
</table>
|
64
|
+
|
65
|
+
<header class="row">
|
66
|
+
<div class="col-sm-12">
|
67
|
+
<h4>
|
68
|
+
<%= t 'History' %>
|
69
|
+
</h4>
|
70
|
+
</div>
|
71
|
+
</header>
|
72
|
+
|
73
|
+
<% if @job.jid_history_from_redis.size > 0 %>
|
74
|
+
<table class="table table-hover table-bordered table-striped">
|
75
|
+
<thead>
|
76
|
+
<tr>
|
77
|
+
<th><%= t 'Enqueued' %></th>
|
78
|
+
<th><%= t 'JID' %></th>
|
79
|
+
</tr>
|
80
|
+
</thead>
|
81
|
+
<tbody>
|
82
|
+
<% @job.jid_history_from_redis.each do |jid_history| %>
|
83
|
+
<tr>
|
84
|
+
<td><%= jid_history['enqueued'] %></td>
|
85
|
+
<td><%= jid_history['jid'] %></td>
|
86
|
+
</tr>
|
87
|
+
<% end %>
|
88
|
+
</tbody>
|
89
|
+
</table>
|
90
|
+
<% else %>
|
91
|
+
<div class='alert alert-success'><%= t 'NoHistoryWereFound' %></div>
|
92
|
+
<% end %>
|
data/lib/sidekiq/cron/web.rb
CHANGED
@@ -1,7 +1,26 @@
|
|
1
1
|
require "sidekiq/cron/web_extension"
|
2
2
|
require "sidekiq/cron/job"
|
3
|
+
require "sidekiq/cron/namespace"
|
3
4
|
|
4
5
|
if defined?(Sidekiq::Web)
|
5
|
-
|
6
|
-
|
6
|
+
if Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('8.0.0')
|
7
|
+
Sidekiq::Web.configure do |config|
|
8
|
+
config.register(
|
9
|
+
Sidekiq::Cron::WebExtension, # Class which contains the HTTP actions, required
|
10
|
+
name: "cron", # the name of the extension, used to namespace assets
|
11
|
+
tab: "Cron", # labels(s) of the UI tabs
|
12
|
+
index: "cron", # index route(s) for each tab
|
13
|
+
)
|
14
|
+
end
|
15
|
+
elsif Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('7.3.0')
|
16
|
+
Sidekiq::Web.register(
|
17
|
+
Sidekiq::Cron::WebExtension, # Class which contains the HTTP actions, required
|
18
|
+
name: "cron", # the name of the extension, used to namespace assets
|
19
|
+
tab: "Cron", # labels(s) of the UI tabs
|
20
|
+
index: "cron", # index route(s) for each tab
|
21
|
+
)
|
22
|
+
else
|
23
|
+
Sidekiq::Web.register Sidekiq::Cron::WebExtension
|
24
|
+
Sidekiq::Web.tabs["Cron"] = "cron"
|
25
|
+
end
|
7
26
|
end
|