sidekiq-cron 1.0.4 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Changes.md +34 -0
- data/Dockerfile +1 -1
- data/Gemfile +1 -30
- data/README.md +149 -65
- data/Rakefile +0 -18
- data/docker-compose.yml +3 -1
- data/lib/sidekiq/cron/job.rb +92 -25
- data/lib/sidekiq/cron/launcher.rb +34 -40
- data/lib/sidekiq/cron/locales/de.yml +1 -1
- data/lib/sidekiq/cron/locales/en.yml +5 -1
- data/lib/sidekiq/cron/locales/ja.yml +1 -1
- data/lib/sidekiq/cron/locales/ru.yml +1 -1
- data/lib/sidekiq/cron/locales/zh-CN.yml +1 -1
- data/lib/sidekiq/cron/poller.rb +5 -5
- data/lib/sidekiq/cron/version.rb +7 -0
- data/lib/sidekiq/cron/views/cron.erb +8 -6
- data/lib/sidekiq/cron/views/cron.slim +5 -4
- data/lib/sidekiq/cron/views/cron_show.erb +88 -0
- data/lib/sidekiq/cron/views/cron_show.slim +61 -0
- data/lib/sidekiq/cron/web_extension.rb +20 -3
- data/lib/sidekiq/cron.rb +1 -0
- data/sidekiq-cron.gemspec +29 -108
- data/test/integration/performance_test.rb +3 -5
- data/test/test_helper.rb +30 -19
- data/test/unit/job_test.rb +134 -3
- data/test/unit/poller_test.rb +1 -3
- data/test/unit/web_extension_test.rb +56 -36
- metadata +33 -159
- data/.travis.yml +0 -21
- data/VERSION +0 -1
data/lib/sidekiq/cron/job.rb
CHANGED
@@ -13,7 +13,9 @@ module Sidekiq
|
|
13
13
|
#how long we would like to store informations about previous enqueues
|
14
14
|
REMEMBER_THRESHOLD = 24 * 60 * 60
|
15
15
|
LAST_ENQUEUE_TIME_FORMAT = '%Y-%m-%d %H:%M:%S %z'
|
16
|
-
|
16
|
+
|
17
|
+
# Use the exists? method if we're on a newer version of redis.
|
18
|
+
REDIS_EXISTS_METHOD = Gem.loaded_specs['redis'].version < Gem::Version.new('4.2') ? :exists : :exists?
|
17
19
|
|
18
20
|
#crucial part of whole enquing job
|
19
21
|
def should_enque? time
|
@@ -57,21 +59,23 @@ module Sidekiq
|
|
57
59
|
nil
|
58
60
|
end
|
59
61
|
|
60
|
-
|
61
|
-
if
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
if @active_job
|
68
|
-
Sidekiq::Client.push(active_job_message)
|
62
|
+
jid =
|
63
|
+
if klass_const
|
64
|
+
if defined?(ActiveJob::Base) && klass_const < ActiveJob::Base
|
65
|
+
enqueue_active_job(klass_const).try :provider_job_id
|
66
|
+
else
|
67
|
+
enqueue_sidekiq_worker(klass_const)
|
68
|
+
end
|
69
69
|
else
|
70
|
-
|
70
|
+
if @active_job
|
71
|
+
Sidekiq::Client.push(active_job_message)
|
72
|
+
else
|
73
|
+
Sidekiq::Client.push(sidekiq_worker_message)
|
74
|
+
end
|
71
75
|
end
|
72
|
-
end
|
73
76
|
|
74
77
|
save_last_enqueue_time
|
78
|
+
add_jid_history jid
|
75
79
|
logger.debug { "enqueued #{@name}: #{@message}" }
|
76
80
|
end
|
77
81
|
|
@@ -83,14 +87,10 @@ module Sidekiq
|
|
83
87
|
|
84
88
|
def enqueue_active_job(klass_const)
|
85
89
|
klass_const.set(queue: @queue).perform_later(*@args)
|
86
|
-
|
87
|
-
true
|
88
90
|
end
|
89
91
|
|
90
92
|
def enqueue_sidekiq_worker(klass_const)
|
91
93
|
klass_const.set(queue: queue_name_with_prefix).perform_async(*@args)
|
92
|
-
|
93
|
-
true
|
94
94
|
end
|
95
95
|
|
96
96
|
# siodekiq worker message
|
@@ -206,9 +206,9 @@ module Sidekiq
|
|
206
206
|
job_hashes = nil
|
207
207
|
Sidekiq.redis do |conn|
|
208
208
|
set_members = conn.smembers(jobs_key)
|
209
|
-
job_hashes = conn.pipelined do
|
209
|
+
job_hashes = conn.pipelined do |pipeline|
|
210
210
|
set_members.each do |key|
|
211
|
-
|
211
|
+
pipeline.hgetall(key)
|
212
212
|
end
|
213
213
|
end
|
214
214
|
end
|
@@ -236,7 +236,7 @@ module Sidekiq
|
|
236
236
|
output = Job.new conn.hgetall( redis_key(name) )
|
237
237
|
end
|
238
238
|
end
|
239
|
-
output
|
239
|
+
output if output && output.valid?
|
240
240
|
end
|
241
241
|
|
242
242
|
# create new instance of cron job
|
@@ -282,7 +282,9 @@ module Sidekiq
|
|
282
282
|
end
|
283
283
|
|
284
284
|
#get right arguments for job
|
285
|
+
@symbolize_args = args["symbolize_args"] == true || ("#{args["symbolize_args"]}" =~ (/^(true|t|yes|y|1)$/i)) == 0 || false
|
285
286
|
@args = args["args"].nil? ? [] : parse_args( args["args"] )
|
287
|
+
@args += [Time.now.to_f] if args["date_as_argument"]
|
286
288
|
|
287
289
|
@active_job = args["active_job"] == true || ("#{args["active_job"]}" =~ (/^(true|t|yes|y|1)$/i)) == 0 || false
|
288
290
|
@active_job_queue_name_prefix = args["queue_name_prefix"]
|
@@ -350,6 +352,12 @@ module Sidekiq
|
|
350
352
|
!enabled?
|
351
353
|
end
|
352
354
|
|
355
|
+
def pretty_message
|
356
|
+
JSON.pretty_generate Sidekiq.load_json(message)
|
357
|
+
rescue JSON::ParserError
|
358
|
+
message
|
359
|
+
end
|
360
|
+
|
353
361
|
def status_from_redis
|
354
362
|
out = "enabled"
|
355
363
|
if fetch_missing_args
|
@@ -371,6 +379,18 @@ module Sidekiq
|
|
371
379
|
out
|
372
380
|
end
|
373
381
|
|
382
|
+
def jid_history_from_redis
|
383
|
+
out =
|
384
|
+
Sidekiq.redis do |conn|
|
385
|
+
conn.lrange(jid_history_key, 0, -1) rescue nil
|
386
|
+
end
|
387
|
+
|
388
|
+
# returns nil if out nil
|
389
|
+
out && out.map do |jid_history_raw|
|
390
|
+
Sidekiq.load_json jid_history_raw
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
374
394
|
#export job data to hash
|
375
395
|
def to_hash
|
376
396
|
{
|
@@ -385,6 +405,7 @@ module Sidekiq
|
|
385
405
|
queue_name_prefix: @active_job_queue_name_prefix,
|
386
406
|
queue_name_delimiter: @active_job_queue_name_delimiter,
|
387
407
|
last_enqueue_time: @last_enqueue_time,
|
408
|
+
symbolize_args: @symbolize_args,
|
388
409
|
}
|
389
410
|
end
|
390
411
|
|
@@ -445,7 +466,7 @@ module Sidekiq
|
|
445
466
|
|
446
467
|
#add information about last time! - don't enque right after scheduler poller starts!
|
447
468
|
time = Time.now.utc
|
448
|
-
conn.zadd(job_enqueued_key, time.to_f.to_s, formated_last_time(time).to_s) unless conn.
|
469
|
+
conn.zadd(job_enqueued_key, time.to_f.to_s, formated_last_time(time).to_s) unless conn.public_send(REDIS_EXISTS_METHOD, job_enqueued_key)
|
449
470
|
end
|
450
471
|
logger.info { "Cron Jobs - add job with name: #{@name}" }
|
451
472
|
end
|
@@ -457,6 +478,20 @@ module Sidekiq
|
|
457
478
|
end
|
458
479
|
end
|
459
480
|
|
481
|
+
def add_jid_history(jid)
|
482
|
+
jid_history = {
|
483
|
+
jid: jid,
|
484
|
+
enqueued: @last_enqueue_time
|
485
|
+
}
|
486
|
+
@history_size ||= (Sidekiq.options[:cron_history_size] || 10).to_i - 1
|
487
|
+
Sidekiq.redis do |conn|
|
488
|
+
conn.lpush jid_history_key,
|
489
|
+
Sidekiq.dump_json(jid_history)
|
490
|
+
# keep only last 10 entries in a fifo manner
|
491
|
+
conn.ltrim jid_history_key, 0, @history_size
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
460
495
|
# remove job from cron jobs by name
|
461
496
|
# input:
|
462
497
|
# first arg: name (string) - name of job (must be same - case sensitive)
|
@@ -468,6 +503,9 @@ module Sidekiq
|
|
468
503
|
#delete runned timestamps
|
469
504
|
conn.del job_enqueued_key
|
470
505
|
|
506
|
+
# delete jid_history
|
507
|
+
conn.del jid_history_key
|
508
|
+
|
471
509
|
#delete main job
|
472
510
|
conn.del redis_key
|
473
511
|
end
|
@@ -507,7 +545,7 @@ module Sidekiq
|
|
507
545
|
def self.exists? name
|
508
546
|
out = false
|
509
547
|
Sidekiq.redis do |conn|
|
510
|
-
out = conn.
|
548
|
+
out = conn.public_send(REDIS_EXISTS_METHOD, redis_key(name))
|
511
549
|
end
|
512
550
|
out
|
513
551
|
end
|
@@ -538,23 +576,44 @@ module Sidekiq
|
|
538
576
|
case args
|
539
577
|
when String
|
540
578
|
begin
|
541
|
-
Sidekiq.load_json(args)
|
579
|
+
parsed_args = Sidekiq.load_json(args)
|
580
|
+
symbolize_args? ? symbolize_args(parsed_args) : parsed_args
|
542
581
|
rescue JSON::ParserError
|
543
582
|
[*args] # cast to string array
|
544
583
|
end
|
545
584
|
when Hash
|
546
|
-
[args]
|
585
|
+
symbolize_args? ? [symbolize_args(args)] : [args]
|
547
586
|
when Array
|
548
|
-
|
587
|
+
symbolize_args? ? symbolize_args(args) : args
|
549
588
|
else
|
550
589
|
[*args] # cast to string array
|
551
590
|
end
|
552
591
|
end
|
553
592
|
|
593
|
+
def symbolize_args?
|
594
|
+
@symbolize_args
|
595
|
+
end
|
596
|
+
|
597
|
+
def symbolize_args(input)
|
598
|
+
if input.is_a?(Array)
|
599
|
+
input.map do |arg|
|
600
|
+
if arg.respond_to?(:symbolize_keys)
|
601
|
+
arg.symbolize_keys
|
602
|
+
else
|
603
|
+
arg
|
604
|
+
end
|
605
|
+
end
|
606
|
+
elsif input.is_a?(Hash) && input.respond_to?(:symbolize_keys)
|
607
|
+
input.symbolize_keys
|
608
|
+
else
|
609
|
+
input
|
610
|
+
end
|
611
|
+
end
|
612
|
+
|
554
613
|
def parse_enqueue_time(timestamp)
|
555
614
|
DateTime.strptime(timestamp, LAST_ENQUEUE_TIME_FORMAT).to_time.utc
|
556
615
|
rescue ArgumentError
|
557
|
-
DateTime.
|
616
|
+
DateTime.parse(timestamp).to_time.utc
|
558
617
|
end
|
559
618
|
|
560
619
|
def not_past_scheduled_time?(current_time)
|
@@ -586,12 +645,20 @@ module Sidekiq
|
|
586
645
|
"cron_job:#{name}:enqueued"
|
587
646
|
end
|
588
647
|
|
648
|
+
def self.jid_history_key name
|
649
|
+
"cron_job:#{name}:jid_history"
|
650
|
+
end
|
651
|
+
|
589
652
|
# Redis key for storing one cron job run times
|
590
653
|
# (when poller added job to queue)
|
591
654
|
def job_enqueued_key
|
592
655
|
self.class.job_enqueued_key @name
|
593
656
|
end
|
594
657
|
|
658
|
+
def jid_history_key
|
659
|
+
self.class.jid_history_key @name
|
660
|
+
end
|
661
|
+
|
595
662
|
# Give Hash
|
596
663
|
# returns array for using it for redis.hmset
|
597
664
|
def hash_to_redis hash
|
@@ -1,6 +1,3 @@
|
|
1
|
-
# require Sidekiq original launcher
|
2
|
-
require 'sidekiq/launcher'
|
3
|
-
|
4
1
|
# require cron poller
|
5
2
|
require 'sidekiq/cron/poller'
|
6
3
|
|
@@ -10,44 +7,41 @@ require 'sidekiq/cron/poller'
|
|
10
7
|
# we are creating new cron poller instance and
|
11
8
|
# adding start and stop commands to launcher
|
12
9
|
module Sidekiq
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
old_quiet
|
10
|
+
module Cron
|
11
|
+
module Launcher
|
12
|
+
# Add cron poller to launcher
|
13
|
+
attr_reader :cron_poller
|
14
|
+
|
15
|
+
# add cron poller and execute normal initialize of Sidekiq launcher
|
16
|
+
def initialize(options)
|
17
|
+
@cron_poller = Sidekiq::Cron::Poller.new
|
18
|
+
super(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
# execute normal run of launcher and run cron poller
|
22
|
+
def run
|
23
|
+
super
|
24
|
+
cron_poller.start
|
25
|
+
end
|
26
|
+
|
27
|
+
# execute normal quiet of launcher and quiet cron poller
|
28
|
+
def quiet
|
29
|
+
cron_poller.terminate
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
# execute normal stop of launcher and stop cron poller
|
34
|
+
def stop
|
35
|
+
cron_poller.terminate
|
36
|
+
super
|
37
|
+
end
|
42
38
|
end
|
39
|
+
end
|
40
|
+
end
|
43
41
|
|
44
|
-
|
45
|
-
|
42
|
+
Sidekiq.configure_server do
|
43
|
+
# require Sidekiq original launcher
|
44
|
+
require 'sidekiq/launcher'
|
46
45
|
|
47
|
-
|
48
|
-
def stop
|
49
|
-
cron_poller.terminate
|
50
|
-
old_stop
|
51
|
-
end
|
52
|
-
end
|
46
|
+
::Sidekiq::Launcher.prepend(Sidekiq::Cron::Launcher)
|
53
47
|
end
|
@@ -8,11 +8,15 @@ en:
|
|
8
8
|
EnqueueAll: Enqueue All
|
9
9
|
DeleteAll: Delete All
|
10
10
|
'Cron string': Cron
|
11
|
+
AreYouSureEnqueueCronJobs: Are you sure you want to enqueue ALL cron jobs?
|
12
|
+
AreYouSureEnqueueCronJob: Are you sure you want to enqueue the %{job} cron job?
|
11
13
|
AreYouSureDeleteCronJobs: Are you sure you want to delete ALL cron jobs?
|
12
14
|
AreYouSureDeleteCronJob: Are you sure you want to delete the %{job} cron job?
|
13
15
|
NoCronJobsWereFound: No cron jobs were found
|
14
16
|
Enable: Enable
|
15
17
|
Disable: Disable
|
16
|
-
'Last
|
18
|
+
'Last enqueued': Last enqueued
|
17
19
|
disabled: disabled
|
18
20
|
enabled: enabled
|
21
|
+
NoHistoryWereFound: No history were found
|
22
|
+
Description: Description
|
data/lib/sidekiq/cron/poller.rb
CHANGED
@@ -17,8 +17,8 @@ module Sidekiq
|
|
17
17
|
rescue => ex
|
18
18
|
# Most likely a problem with redis networking.
|
19
19
|
# Punt and try again at the next interval
|
20
|
-
logger.error ex.message
|
21
|
-
logger.error ex.backtrace.first
|
20
|
+
Sidekiq.logger.error ex.message
|
21
|
+
Sidekiq.logger.error ex.backtrace.first
|
22
22
|
handle_exception(ex) if respond_to?(:handle_exception)
|
23
23
|
end
|
24
24
|
|
@@ -28,13 +28,13 @@ module Sidekiq
|
|
28
28
|
job.test_and_enque_for_time! time if job && job.valid?
|
29
29
|
rescue => ex
|
30
30
|
# problem somewhere in one job
|
31
|
-
logger.error "CRON JOB: #{ex.message}"
|
32
|
-
logger.error "CRON JOB: #{ex.backtrace.first}"
|
31
|
+
Sidekiq.logger.error "CRON JOB: #{ex.message}"
|
32
|
+
Sidekiq.logger.error "CRON JOB: #{ex.backtrace.first}"
|
33
33
|
handle_exception(ex) if respond_to?(:handle_exception)
|
34
34
|
end
|
35
35
|
|
36
36
|
def poll_interval_average
|
37
|
-
Sidekiq.options[:poll_interval] || POLL_INTERVAL
|
37
|
+
Sidekiq.options[:average_scheduled_poll_interval] || Sidekiq.options[:poll_interval] || POLL_INTERVAL
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<header class='row'>
|
2
2
|
<div class='col-sm-5 pull-left'>
|
3
|
-
<h3><%=t
|
3
|
+
<h3><%= t('CronJobs') %></h3>
|
4
4
|
</div>
|
5
5
|
<div class='col-sm-7 pull-right' style="margin-top: 20px; margin-bottom: 10px;">
|
6
6
|
<% if @cron_jobs.size > 0 %>
|
7
7
|
<form action="<%= root_path %>cron/__all__/delete" method="post" class="pull-right">
|
8
8
|
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
9
|
-
<input class="btn btn-small btn-danger" type="submit" name="delete" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSureDeleteCronJobs') %>"
|
9
|
+
<input class="btn btn-small btn-danger" type="submit" name="delete" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSureDeleteCronJobs') %>" />
|
10
10
|
</form>
|
11
11
|
<form action="<%= root_path %>cron/__all__/disable" method="post" class="pull-right">
|
12
12
|
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
</form>
|
19
19
|
<form action="<%= root_path %>cron/__all__/enque" method="post" class="pull-right">
|
20
20
|
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
21
|
-
<input class="btn btn-small" type="submit" name="enque" value="<%= t('EnqueueAll') %>" />
|
21
|
+
<input class="btn btn-small" type="submit" name="enque" value="<%= t('EnqueueAll') %>" data-confirm="<%= t('AreYouSureEnqueueCronJobs') %>" />
|
22
22
|
</form>
|
23
23
|
<% end %>
|
24
24
|
</div>
|
@@ -31,7 +31,7 @@
|
|
31
31
|
<th><%= t('Status') %></th>
|
32
32
|
<th><%= t('Name') %></th>
|
33
33
|
<th><%= t('Cron string') %></th>
|
34
|
-
<th><%= t('Last
|
34
|
+
<th><%= t('Last enqueued') %></th>
|
35
35
|
<th width="180"><%= t('Actions')%></th>
|
36
36
|
</thead>
|
37
37
|
|
@@ -41,7 +41,9 @@
|
|
41
41
|
<tr>
|
42
42
|
<td style="<%= style %>"><%= t job.status %></td>
|
43
43
|
<td style="<%= style %>">
|
44
|
-
<
|
44
|
+
<a href="<%= root_path %>cron/<%= CGI.escape(job.name).gsub('+', '%20') %>">
|
45
|
+
<b><%= job.name %></b>
|
46
|
+
</a>
|
45
47
|
<hr style="margin:3px;border:0;">
|
46
48
|
<small>
|
47
49
|
<% if job.message and job.message.to_s.size > 100 %>
|
@@ -59,7 +61,7 @@
|
|
59
61
|
<% if job.status == 'enabled' %>
|
60
62
|
<form action="<%= root_path %>cron/<%= CGI.escape(job.name).gsub('+', '%20') %>/enque" method="post">
|
61
63
|
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
62
|
-
<input class='btn btn-xs pull-left' type="submit" name="enque" value="<%= t('EnqueueNow') %>"/>
|
64
|
+
<input class='btn btn-xs pull-left' type="submit" name="enque" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => job.name) %>"/>
|
63
65
|
</form>
|
64
66
|
<form action="<%= root_path %>cron/<%= CGI.escape(job.name).gsub('+', '%20') %>/disable" method="post">
|
65
67
|
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
@@ -15,7 +15,7 @@ header.row
|
|
15
15
|
input.btn.btn-small.pull-left type="submit" name="enque" value="#{t('EnableAll')}"
|
16
16
|
form.pull-right action="#{root_path}cron/__all__/enque" method="post"
|
17
17
|
= csrf_tag if respond_to?(:csrf_tag)
|
18
|
-
input.btn.btn-small.pull-left type="submit" name="enque" value="#{t('EnqueueAll')}"
|
18
|
+
input.btn.btn-small.pull-left type="submit" name="enque" value="#{t('EnqueueAll')}" data-confirm="#{t('AreYouSureEnqueueCronJobs')}"
|
19
19
|
|
20
20
|
- if @cron_jobs.size > 0
|
21
21
|
|
@@ -24,7 +24,7 @@ header.row
|
|
24
24
|
th = t('Status')
|
25
25
|
th = t('Name')
|
26
26
|
th = t('Cron')
|
27
|
-
th = t('Last
|
27
|
+
th = t('Last enqueued')
|
28
28
|
th width="180px"
|
29
29
|
= t('Actions')
|
30
30
|
|
@@ -34,7 +34,8 @@ header.row
|
|
34
34
|
tr
|
35
35
|
td[style="#{style}"]= job.status
|
36
36
|
td[style="#{style}"]
|
37
|
-
|
37
|
+
a href="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}"
|
38
|
+
b = job.name
|
38
39
|
hr style="margin:3px;border:0;"
|
39
40
|
small
|
40
41
|
- if job.message and job.message.to_s.size > 100
|
@@ -58,7 +59,7 @@ header.row
|
|
58
59
|
-else
|
59
60
|
form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/enque" method="post"
|
60
61
|
= csrf_tag if respond_to?(:csrf_tag)
|
61
|
-
input.btn.btn-small.pull-left type="submit" name="enque" value="#{t('EnqueueNow')}"
|
62
|
+
input.btn.btn-small.pull-left type="submit" name="enque" value="#{t('EnqueueNow')}" data-confirm="#{t('AreYouSureEnqueueCronJob', :job => job.name)}"
|
62
63
|
form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/enable" method="post"
|
63
64
|
= csrf_tag if respond_to?(:csrf_tag)
|
64
65
|
input.btn.btn-small.pull-left type="submit" name="enable" value="#{t('Enable')}"
|
@@ -0,0 +1,88 @@
|
|
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" style="margin-top: 20px; margin-bottom: 10px;">
|
9
|
+
<% cron_job_path = "#{root_path}cron/#{CGI.escape(@job.name).gsub('+', '%20')}" %>
|
10
|
+
<form action="<%= cron_job_path %>/enque?redirect=<%= cron_job_path %>" class="pull-right" method="post">
|
11
|
+
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
12
|
+
<input class="btn btn-small pull-left" name="enque" 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 if respond_to?(:csrf_tag) %>
|
17
|
+
<input class="btn btn-small 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 if respond_to?(:csrf_tag) %>
|
22
|
+
<input class="btn btn-small 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 if respond_to?(:csrf_tag) %>
|
26
|
+
<input class="btn btn-danger btn-small" 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 '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>
|
77
|
+
<tbody>
|
78
|
+
<% @job.jid_history_from_redis.each do |jid_history| %>
|
79
|
+
<tr>
|
80
|
+
<td><%= jid_history['enqueued'] %></td>
|
81
|
+
<td><%= jid_history['jid'] %></td>
|
82
|
+
</tr>
|
83
|
+
<% end %>
|
84
|
+
</tbody>
|
85
|
+
</table>
|
86
|
+
<% else %>
|
87
|
+
<div class='alert alert-success'><%= t 'NoHistoryWereFound' %></div>
|
88
|
+
<% end %>
|
@@ -0,0 +1,61 @@
|
|
1
|
+
header.row
|
2
|
+
.span.col-sm-5.pull-left
|
3
|
+
h3
|
4
|
+
= "#{t('Cron')} #{t('Job')}"
|
5
|
+
small= @job.name
|
6
|
+
.span.col-sm-7.pull-right style=("margin-top: 20px; margin-bottom: 10px;")
|
7
|
+
- cron_job_path = "#{root_path}cron/#{CGI.escape(@job.name).gsub('+', '%20')}"
|
8
|
+
form.pull-right action="#{cron_job_path}/enque?redirect=#{cron_job_path}" method="post"
|
9
|
+
= csrf_tag if respond_to?(:csrf_tag)
|
10
|
+
input.btn.btn-small.pull-left data-confirm="#{t('AreYouSureEnqueueCronJob', :job => @job.name)}" name="enque" type="submit" value="#{t('EnqueueNow')}"
|
11
|
+
- if @job.status == 'enabled'
|
12
|
+
form.pull-right action="#{cron_job_path}/disable?redirect=#{cron_job_path}" method="post"
|
13
|
+
= csrf_tag if respond_to?(:csrf_tag)
|
14
|
+
input.btn.btn-small.pull-left name="disable" type="submit" value="#{t('Disable')}"
|
15
|
+
- else
|
16
|
+
form.pull-right action="#{cron_job_path}/enable?redirect=#{cron_job_path}" method="post"
|
17
|
+
= csrf_tag if respond_to?(:csrf_tag)
|
18
|
+
input.btn.btn-small.pull-left name="enable" type="submit" value="#{t('Enable')}"
|
19
|
+
form.pull-right action="#{cron_job_path}/delete" method="post"
|
20
|
+
= csrf_tag if respond_to?(:csrf_tag)
|
21
|
+
input.btn.btn-danger.btn-small data-confirm="#{t('AreYouSureDeleteCronJob', :job => @job.name)}" name="delete" type="submit" value="#{t('Delete')}" /
|
22
|
+
|
23
|
+
table.table.table-bordered.table-striped
|
24
|
+
tbody
|
25
|
+
tr
|
26
|
+
th= t 'Status'
|
27
|
+
td= @job.status
|
28
|
+
tr
|
29
|
+
th= t 'Name'
|
30
|
+
td= @job.name
|
31
|
+
tr
|
32
|
+
th= t 'Description'
|
33
|
+
td= @job.description
|
34
|
+
tr
|
35
|
+
th= t 'Message'
|
36
|
+
td
|
37
|
+
pre= @job.pretty_message
|
38
|
+
tr
|
39
|
+
th= t 'Cron'
|
40
|
+
td= @job.cron.gsub(" ", " ")
|
41
|
+
tr
|
42
|
+
th= t 'Last enqueued'
|
43
|
+
td= @job.last_enqueue_time ? relative_time(@job.last_enqueue_time) : "-"
|
44
|
+
|
45
|
+
header.row
|
46
|
+
.col-sm-12
|
47
|
+
h4= t 'History'
|
48
|
+
|
49
|
+
- if @job.jid_history_from_redis.size > 0
|
50
|
+
table.table.table-hover.table-bordered.table-striped
|
51
|
+
thead
|
52
|
+
tr
|
53
|
+
th= t 'Enqueued'
|
54
|
+
th= t 'JID'
|
55
|
+
tbody
|
56
|
+
- @job.jid_history_from_redis.each do |jid_history|
|
57
|
+
tr
|
58
|
+
td= jid_history['enqueued']
|
59
|
+
td= jid_history['jid']
|
60
|
+
- else
|
61
|
+
.alert.alert-success= t 'NoHistoryWereFound'
|