web47core 2.0.1 → 2.2.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +111 -41
- data/app/controllers/status_controller.rb +8 -3
- data/app/helpers/core_form_helper.rb +6 -6
- data/app/helpers/core_helper.rb +1 -1
- data/app/helpers/core_link_helper.rb +47 -8
- data/app/helpers/core_nav_bar_helper.rb +5 -4
- data/app/helpers/core_table_helper.rb +80 -0
- data/app/helpers/model_modal_helper.rb +3 -3
- data/app/views/common/_create_actions.html.haml +12 -0
- data/app/views/common/_update_actions.html.haml +10 -0
- data/app/views/cron/_edit.html.haml +15 -17
- data/app/views/cron/_index.html.haml +74 -67
- data/app/views/delayed_job_metrics/_index.html.haml +27 -0
- data/app/views/delayed_job_metrics/index.html.haml +1 -0
- data/app/views/delayed_job_workers/_index.html.haml +27 -0
- data/app/views/delayed_job_workers/index.html.haml +1 -0
- data/app/views/delayed_jobs/_index.html.haml +47 -52
- data/app/views/delayed_jobs/_show.html.haml +15 -13
- data/app/views/system_configurations/_edit.html.haml +14 -9
- data/app/views/system_configurations/_show.html.haml +18 -12
- data/config/brakeman.ignore +26 -0
- data/config/brakeman.yml +2 -0
- data/config/locales/en.yml +21 -3
- data/lib/app/controllers/concerns/core_delayed_job_metrics_controller.rb +35 -0
- data/lib/app/controllers/concerns/core_delayed_job_workers_controller.rb +35 -0
- data/lib/app/controllers/concerns/core_delayed_jobs_controller.rb +2 -3
- data/lib/app/jobs/cron/command.rb +1 -4
- data/lib/app/jobs/cron/record_delayed_job_metrics.rb +25 -0
- data/lib/app/jobs/cron/restart_orphaned_delayed_jobs.rb +44 -0
- data/lib/app/jobs/cron/server.rb +32 -15
- data/lib/app/jobs/cron/switchboard_sync_configuration.rb +2 -0
- data/lib/app/jobs/cron/switchboard_sync_models.rb +2 -0
- data/lib/app/jobs/cron/trim_collection.rb +1 -1
- data/lib/app/jobs/cron/trim_delayed_job_metrics.rb +29 -0
- data/lib/app/jobs/cron/trim_delayed_job_workers.rb +39 -0
- data/lib/app/jobs/cron/trim_failed_delayed_jobs.rb +2 -0
- data/lib/app/models/api_token.rb +9 -0
- data/lib/app/models/command_job.rb +12 -11
- data/lib/app/models/concerns/api_tokenable.rb +38 -0
- data/lib/app/models/concerns/aws_configuration.rb +65 -0
- data/lib/app/models/concerns/cdn_url.rb +7 -0
- data/lib/app/models/concerns/core_smtp_configuration.rb +65 -0
- data/lib/app/models/concerns/core_system_configuration.rb +18 -201
- data/lib/app/models/concerns/delayed_job_configuration.rb +24 -0
- data/lib/app/models/concerns/email_able.rb +6 -2
- data/lib/app/models/concerns/google_sso_configuration.rb +32 -0
- data/lib/app/models/concerns/search_able.rb +16 -0
- data/lib/app/models/concerns/server_process_able.rb +69 -0
- data/lib/app/models/concerns/slack_configuration.rb +38 -0
- data/lib/app/models/concerns/standard_model.rb +5 -2
- data/lib/app/models/concerns/switchboard_configuration.rb +43 -0
- data/lib/app/models/concerns/twilio_configuration.rb +37 -0
- data/lib/app/models/concerns/zendesk_configuration.rb +92 -0
- data/lib/app/models/{delayed_job.rb → delayed/backend/delayed_job.rb} +41 -0
- data/lib/app/models/delayed/jobs/metric.rb +61 -0
- data/lib/app/models/delayed/jobs/run.rb +40 -0
- data/lib/app/models/delayed/jobs/worker.rb +43 -0
- data/lib/app/models/delayed/plugins/time_keeper.rb +33 -0
- data/lib/app/models/delayed/worker.rb +24 -0
- data/lib/app/models/email_notification.rb +2 -1
- data/lib/app/models/email_template.rb +5 -6
- data/lib/app/models/notification.rb +12 -2
- data/lib/app/models/sms_notification.rb +9 -6
- data/lib/app/models/template.rb +12 -12
- data/lib/web47core/version.rb +1 -1
- data/lib/web47core.rb +33 -9
- metadata +114 -69
@@ -1,70 +1,77 @@
|
|
1
|
-
- title t('.title')
|
1
|
+
- title t('cron.index.title')
|
2
2
|
.container
|
3
3
|
.row
|
4
4
|
.col.s12
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
5
|
+
.card
|
6
|
+
.card-content
|
7
|
+
.card-title= t('cron.index.title')
|
8
|
+
.card.section-data-tables
|
9
|
+
.card-content
|
10
|
+
%ul.tabs#stack_cron
|
11
|
+
%li.tab.col.s6
|
12
|
+
%a{href: '#cron_job_servers'}='Cron Servers'
|
13
|
+
%li.tab.col.s6
|
14
|
+
%a{href: '#job_cron_tabs'}='Cron Jobs'
|
15
|
+
.container
|
16
|
+
.row
|
17
|
+
.col.s12
|
18
|
+
#cron_job_servers{data: {cache: 'stack_cron'}}
|
19
|
+
%table.highlight.data-table
|
20
|
+
%thead
|
21
|
+
%tr
|
22
|
+
= table_header_tag :host
|
23
|
+
= table_header_tag :state, priority: 3
|
24
|
+
= table_header_tag :last_check_in_at, priority: 4
|
25
|
+
= table_header_actions_tag
|
26
|
+
%tbody.white-text
|
27
|
+
- Cron::Server.all.each do |server|
|
28
|
+
%tr{class: server.alive? ? 'green lighten-1' : 'red lighten-1'}
|
29
|
+
%td="#{server.host_name}:#{server.pid}"
|
30
|
+
%td.center-align
|
31
|
+
- if server.primary?
|
32
|
+
%i.material-icons.white-text
|
33
|
+
grade
|
34
|
+
- else
|
35
|
+
|
36
|
+
%td=current_user.local_time(server.last_check_in_at)
|
37
|
+
%td.center-align
|
38
|
+
- if can? :manage, server
|
39
|
+
.actions
|
40
|
+
- if server.primary?
|
41
|
+
= action_link_tag(can?(:manage, Cron::Server), model_action_path(server, :demote), icon_name: 'thumb_down' )
|
42
|
+
- else
|
43
|
+
= delete_link_tag(server, model_path(server))
|
44
|
+
.col.s12
|
45
|
+
#job_cron_tabs{data: {cache: 'stack_cron'}}
|
46
|
+
%table.highlight.data-table
|
47
|
+
%thead
|
48
|
+
%tr
|
49
|
+
= table_header_tag :name
|
50
|
+
= table_header_tag :last_run_at, priority: 4
|
51
|
+
= table_header_tag :min, priority: 5
|
52
|
+
= table_header_tag :hour, priority: 6
|
53
|
+
= table_header_tag :mday, priority: 7
|
54
|
+
= table_header_tag :month, priority: 8
|
55
|
+
= table_header_tag :wday, priority: 9
|
56
|
+
= table_header_tag :enabled, priority: 3
|
57
|
+
= table_header_actions_tag
|
58
|
+
%tbody
|
59
|
+
- Cron::JobTab.matching_search_text(params[:search]).each do |cron_tab|
|
60
|
+
%tr
|
61
|
+
%td.name=cron_tab.name.humanize
|
62
|
+
%td=current_user.local_time(cron_tab.last_run_at)
|
63
|
+
%td=cron_tab.min
|
64
|
+
%td=cron_tab.hour
|
65
|
+
%td=cron_tab.mday
|
66
|
+
%td=cron_tab.month
|
67
|
+
%td=cron_tab.wday
|
68
|
+
%td
|
69
|
+
- if cron_tab.valid_environment?
|
70
|
+
%i.material-icons.green-text
|
71
|
+
check
|
72
|
+
- else
|
73
|
+
%nbsp
|
74
|
+
%td.actions
|
75
|
+
= edit_link_tag(cron_tab, edit_model_path(cron_tab))
|
76
|
+
- if cron_tab.valid_environment?
|
77
|
+
= replay_link_tag(cron_tab, model_action_path(cron_tab, :run_now), icon_name: 'directions_run', confirm: t('.confirm', name: cron_tab.name.humanize))
|
@@ -0,0 +1,27 @@
|
|
1
|
+
- title t('.title')
|
2
|
+
.container
|
3
|
+
.row
|
4
|
+
.s12
|
5
|
+
.card.section-data-tables
|
6
|
+
.card-content
|
7
|
+
%table.highlight.data-table
|
8
|
+
%thead
|
9
|
+
%tr
|
10
|
+
=table_header_tag :name
|
11
|
+
=table_header_tag :count, priority: 3
|
12
|
+
=table_header_tag :min, priority: 5
|
13
|
+
=table_header_tag :avg, priority: 5
|
14
|
+
=table_header_tag :max, priority: 5
|
15
|
+
=table_header_tag :last_run_at, priority: 4
|
16
|
+
=table_header_actions_tag
|
17
|
+
%tbody
|
18
|
+
- @metrics.each do |metric|
|
19
|
+
%tr
|
20
|
+
%td=metric.name
|
21
|
+
%td=metric.count
|
22
|
+
%td=metric.min.round(3)
|
23
|
+
%td=metric.avg.round(3)
|
24
|
+
%td=metric.max.round(3)
|
25
|
+
%td=current_user.local_time(metric.last_run_at)
|
26
|
+
%td.actions
|
27
|
+
= delete_link_tag(metric, model_path(metric))
|
@@ -0,0 +1 @@
|
|
1
|
+
=render 'index'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
- title t('.title')
|
2
|
+
.container
|
3
|
+
.row
|
4
|
+
.s12
|
5
|
+
.card.section-data-tables
|
6
|
+
.card-content
|
7
|
+
%table.highlight.data-table
|
8
|
+
%thead
|
9
|
+
%tr
|
10
|
+
=table_header_tag :host_name, priority: 3
|
11
|
+
=table_header_tag :pid, priority: 3
|
12
|
+
=table_header_tag :running, priority: 5
|
13
|
+
=table_header_tag :alive, priority: 5
|
14
|
+
=table_header_tag :last_check_in, priority: 4
|
15
|
+
=table_header_tag :runs, priority: 4
|
16
|
+
=table_header_actions_tag
|
17
|
+
%tbody
|
18
|
+
- @workers.each do |worker|
|
19
|
+
%tr
|
20
|
+
%td=worker.host_name
|
21
|
+
%td=worker.pid
|
22
|
+
%td=materialize_icon(worker.running? ? 'directions_run' : 'pending')
|
23
|
+
%td=materialize_icon(worker.dead? ? 'do_disturb' : 'run_circle')
|
24
|
+
%td=current_user.local_time(worker.last_check_in_at)
|
25
|
+
%td=worker.runs.count
|
26
|
+
%td.actions
|
27
|
+
= delete_link_tag(worker, model_path(worker))
|
@@ -0,0 +1 @@
|
|
1
|
+
=render 'index'
|
@@ -1,54 +1,49 @@
|
|
1
1
|
- title t('.title')
|
2
|
-
|
3
|
-
.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
-
|
32
|
-
|
33
|
-
|
34
|
-
.container
|
35
|
-
.row
|
36
|
-
.col.s12
|
37
|
-
%table.highlight.bordered.extended{data: {sort: {column: 'Run At,Priority', direction: 'desc,asc'}}}
|
38
|
-
%thead
|
39
|
-
%tr
|
40
|
-
%th=t('.run_at')
|
41
|
-
%th=t('.name')
|
42
|
-
%th=t('.priority')
|
43
|
-
%th=t('.status')
|
44
|
-
%th=t('.actions')
|
45
|
-
%tbody
|
46
|
-
- @delayed_jobs.each do |delayed_job|
|
2
|
+
.container
|
3
|
+
.row
|
4
|
+
.s12
|
5
|
+
.card
|
6
|
+
.card-content
|
7
|
+
.card-title Delayed Jobs
|
8
|
+
- if can?(:manage, Delayed::Backend::Mongoid::Job)
|
9
|
+
.card-tray
|
10
|
+
%a.btn.yellow{href: class_action_path(:destroy_all, failed_only:true),
|
11
|
+
title: t('.destroy_all'),
|
12
|
+
data: {confirm: t('.confirm_destroy_failed')}}
|
13
|
+
%i.material-icons
|
14
|
+
delete
|
15
|
+
%a.btn.red{href: class_action_path(:destroy_all, failed_only:false),
|
16
|
+
title: t('.destroy_all'),
|
17
|
+
data: {confirm: t('confirm_destroy_all')}}
|
18
|
+
%i.material-icons
|
19
|
+
delete
|
20
|
+
%a.btn.yellow.darken-3{href: class_action_path(:resbumit_all, failed_only:true),
|
21
|
+
title: t('.resubmit_failed'),
|
22
|
+
data: {confirm: t('.confirm_resubmit_failed')}}
|
23
|
+
%i.material-icons
|
24
|
+
restore
|
25
|
+
%a.btn.red{href: class_action_path(:resbumit_all, failed_only:false),
|
26
|
+
title: t('.resubmit_all'),
|
27
|
+
data: {confirm: t('.confirm_resubmit_all')}}
|
28
|
+
%i.material-icons
|
29
|
+
restore
|
30
|
+
.card
|
31
|
+
.card-content
|
32
|
+
%table.highlight.data-table
|
33
|
+
%thead
|
47
34
|
%tr
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
35
|
+
=table_header_tag :run_at, priority: 3
|
36
|
+
=table_header_tag :name
|
37
|
+
=table_header_tag :priority, priority: 5
|
38
|
+
=table_header_tag :status, priority: 4
|
39
|
+
=table_header_actions_tag
|
40
|
+
%tbody
|
41
|
+
- @delayed_jobs.each do |delayed_job|
|
42
|
+
%tr
|
43
|
+
%td=current_user.local_time(delayed_job.created_at)
|
44
|
+
%td.name=link_to(delayed_job.display_name, model_path(delayed_job))
|
45
|
+
%td=delayed_job.priority
|
46
|
+
%td=delayed_job.status_description
|
47
|
+
%td.actions
|
48
|
+
= replay_link_tag(delayed_job, model_action_path(delayed_job, :resubmit), confirm: 'Are you sure you want to restart this job?')
|
49
|
+
= delete_link_tag(delayed_job, model_path(delayed_job))
|
@@ -1,12 +1,16 @@
|
|
1
|
-
- title
|
2
|
-
- content_for :breadcrumbs do
|
3
|
-
%a.breadcrumb{href: index_path}=t('delayed_jobs.index.title')
|
4
|
-
%a.breadcrumb{href: '#'}=t('.title')
|
1
|
+
- title @delayed_job.name
|
5
2
|
.container
|
6
3
|
.row
|
7
4
|
.col.s12
|
8
|
-
.
|
9
|
-
.
|
5
|
+
.card
|
6
|
+
.card-content
|
7
|
+
.card-title= @delayed_job.name
|
8
|
+
- if can?(:manage, @delayed_job)
|
9
|
+
.card-tray
|
10
|
+
=delete_button_tag(@delayed_job, model_path(@delayed_job))
|
11
|
+
=replay_button_tag(@delayed_job, model_path(@delayed_job))
|
12
|
+
.card
|
13
|
+
.card-content
|
10
14
|
%table#info{class: 'bordered'}
|
11
15
|
%tr
|
12
16
|
%th=t('.name_label')
|
@@ -49,10 +53,8 @@
|
|
49
53
|
%tr
|
50
54
|
%th=t('delayed_jobs.show.last_error_label')
|
51
55
|
%td=@delayed_job.last_error
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
.col.s6.center-align
|
58
|
-
= link_to "Resubmit", model_action_path(@delayed_job, :resubmit), class: 'button action', data: {confirm: 'Are you sure you want to resubmit this job?'}
|
56
|
+
- if can? :manage, @delayed_job
|
57
|
+
.card-action
|
58
|
+
.row
|
59
|
+
.col.s6.center-align= delete_button_tag(@delayed_job, model_path(@delayed_job))
|
60
|
+
.col.s6.center-align= replay_button_tag(@delayed_job, model_path(@delayed_job))
|
@@ -1,10 +1,15 @@
|
|
1
|
-
- title
|
2
|
-
|
3
|
-
%
|
4
|
-
|
5
|
-
|
1
|
+
- title SystemConfiguration.environment.titleize
|
2
|
+
%form{action: index_path, method: :post}
|
3
|
+
%input{type: :hidden, value: form_authenticity_token, name: :authenticity_token}
|
4
|
+
%input{type: :hidden, name: '_method', value: :put}
|
5
|
+
.container
|
6
6
|
.row
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
.col.s12
|
8
|
+
.card
|
9
|
+
.card-content
|
10
|
+
.card-title= SystemConfiguration.environment.titleize
|
11
|
+
.row
|
12
|
+
= form_text_field(@system_configuration, :switchboard_base_url, classes: %w[s12 m4])
|
13
|
+
= form_text_field(@system_configuration, :switchboard_stack_id, classes: %w[s12 m4])
|
14
|
+
= form_password(@system_configuration, :switchboard_stack_api_token, classes: %w[s12 m4])
|
15
|
+
= render 'common/update_actions', form_cancel_path: index_path
|
@@ -1,15 +1,21 @@
|
|
1
|
-
- title
|
2
|
-
= edit_class_link_tag(SystemConfiguration, class_action_path(:edit))
|
1
|
+
- title SystemConfiguration.environment.titleize
|
3
2
|
.container
|
4
3
|
.row
|
5
4
|
.s12
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
%
|
5
|
+
.card
|
6
|
+
.card-content
|
7
|
+
.card-title=SystemConfiguration.environment.titleize
|
8
|
+
.card-tray
|
9
|
+
= edit_link_tag(SystemConfiguration, class_action_path(:edit))
|
10
|
+
.card
|
11
|
+
.card-content.section-data-tables
|
12
|
+
%table.highlight.striped.data-table
|
13
|
+
%thead
|
14
|
+
%tr
|
15
|
+
=table_header_tag :field
|
16
|
+
=table_header_tag :value
|
17
|
+
%tbody
|
18
|
+
- SystemConfiguration.allowed_param_names.each do |field|
|
19
|
+
%tr
|
20
|
+
%td=field
|
21
|
+
%td=mask_system_configuration(field)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"ignored_warnings": [
|
3
|
+
{
|
4
|
+
"warning_type": "Command Injection",
|
5
|
+
"warning_code": 14,
|
6
|
+
"fingerprint": "4cde947f1dccdd96581d38647925be10f74835464af7e8790dc776c9160a0453",
|
7
|
+
"check_name": "Execute",
|
8
|
+
"message": "Possible command injection",
|
9
|
+
"file": "lib/app/models/command_job.rb",
|
10
|
+
"line": 316,
|
11
|
+
"link": "https://brakemanscanner.org/docs/warning_types/command_injection/",
|
12
|
+
"code": "`#{command.join(\" \")} > #{Tempfile.new.path} 2>&1`",
|
13
|
+
"render_path": null,
|
14
|
+
"location": {
|
15
|
+
"type": "method",
|
16
|
+
"class": "CommandJob",
|
17
|
+
"method": "run_command"
|
18
|
+
},
|
19
|
+
"user_input": "command.join(\" \")",
|
20
|
+
"confidence": "Medium",
|
21
|
+
"note": "This is the purpose of the method, to run any command, accepted risk by Chris Schroeder"
|
22
|
+
}
|
23
|
+
],
|
24
|
+
"updated": "2021-03-05 09:25:43 -0500",
|
25
|
+
"brakeman_version": "5.0.0"
|
26
|
+
}
|
data/config/brakeman.yml
ADDED
data/config/locales/en.yml
CHANGED
@@ -32,6 +32,7 @@ en:
|
|
32
32
|
delete: Delete
|
33
33
|
info: View
|
34
34
|
replay: Restart
|
35
|
+
favorite: Favorite
|
35
36
|
system_configuration:
|
36
37
|
placeholders:
|
37
38
|
switchboard_base_url: https://switchboard.app47.com
|
@@ -67,10 +68,14 @@ en:
|
|
67
68
|
wday: Week Day
|
68
69
|
enabled: Enabled?
|
69
70
|
actions: Actions
|
70
|
-
host: Host
|
71
|
-
state: State
|
72
71
|
last_run_at: Last Run At
|
73
72
|
confirm: Are you sure you want to run %{name}?
|
73
|
+
delayed_job_workers:
|
74
|
+
index:
|
75
|
+
title: Delayed Job Workers
|
76
|
+
delayed_job_metrics:
|
77
|
+
index:
|
78
|
+
title: Delayed Job Metrics
|
74
79
|
delayed_jobs:
|
75
80
|
index:
|
76
81
|
title: "Delayed Jobs"
|
@@ -101,4 +106,17 @@ en:
|
|
101
106
|
locked_by_label: "Locked by"
|
102
107
|
handler_label: "Handler"
|
103
108
|
failed_at_label: "Failed at"
|
104
|
-
last_error_label: "Last Error"
|
109
|
+
last_error_label: "Last Error"
|
110
|
+
core_table:
|
111
|
+
headers:
|
112
|
+
host: Host
|
113
|
+
state: State
|
114
|
+
last_check_in_at: Last Check In
|
115
|
+
run_at: Run At
|
116
|
+
last_run_at: Last Run
|
117
|
+
name: Name
|
118
|
+
priority: Priority
|
119
|
+
status: Status
|
120
|
+
pid: PID
|
121
|
+
running: Running?
|
122
|
+
alive: Alive?
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Manage access to delayed job workers
|
5
|
+
#
|
6
|
+
module CoreDelayedJobMetricsController
|
7
|
+
include CoreController
|
8
|
+
#
|
9
|
+
# Show a list of workers currently in the system
|
10
|
+
#
|
11
|
+
def index
|
12
|
+
authorize! :read, Delayed::Jobs::Metric
|
13
|
+
@metrics = Delayed::Jobs::Metric.all
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Destroy the selected delayed job worker
|
18
|
+
#
|
19
|
+
def destroy
|
20
|
+
authorize! :manage, delayed_job_metric
|
21
|
+
delayed_job_metric.destroy!
|
22
|
+
flash.now[:info] = 'Delayed Job Metric has been destroyed'
|
23
|
+
redirect_to index_path
|
24
|
+
rescue StandardError => error
|
25
|
+
log_controller_error error, true
|
26
|
+
redirect_to index_path
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Fetch the required job by id
|
31
|
+
#
|
32
|
+
def delayed_job_metric
|
33
|
+
@delayed_job_metric ||= Delayed::Jobs::Metric.find(params[:id])
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Manage access to delayed job workers
|
5
|
+
#
|
6
|
+
module CoreDelayedJobWorkersController
|
7
|
+
include CoreController
|
8
|
+
#
|
9
|
+
# Show a list of workers currently in the system
|
10
|
+
#
|
11
|
+
def index
|
12
|
+
authorize! :read, Delayed::Jobs::Worker
|
13
|
+
@workers = Delayed::Jobs::Worker.all
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Destroy the selected delayed job worker
|
18
|
+
#
|
19
|
+
def destroy
|
20
|
+
authorize! :manage, delayed_job_worker
|
21
|
+
delayed_job_worker.destroy!
|
22
|
+
flash.now[:info] = 'Delayed Job Worker has been destroyed'
|
23
|
+
redirect_to index_path
|
24
|
+
rescue StandardError => error
|
25
|
+
log_controller_error error, true
|
26
|
+
redirect_to index_path
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Fetch the required job by id
|
31
|
+
#
|
32
|
+
def delayed_job_worker
|
33
|
+
@delayed_job_worker ||= Delayed::Jobs::Worker.find(params[:id])
|
34
|
+
end
|
35
|
+
end
|
@@ -90,9 +90,8 @@ module CoreDelayedJobsController
|
|
90
90
|
# Find the first jobs for index or deleting all
|
91
91
|
#
|
92
92
|
def delayed_jobs
|
93
|
-
@delayed_jobs ||= Delayed::Backend::Mongoid::Job
|
94
|
-
|
95
|
-
.limit(delayed_jobs_limit)
|
93
|
+
@delayed_jobs ||= Delayed::Backend::Mongoid::Job.order_by(locked_by: :desc, priority: :asc, run_at: :asc)
|
94
|
+
.limit(delayed_jobs_limit)
|
96
95
|
end
|
97
96
|
|
98
97
|
#
|
@@ -27,9 +27,6 @@ module Cron
|
|
27
27
|
warn opt
|
28
28
|
exit 1
|
29
29
|
end
|
30
|
-
opt.on('-e', '--environment=NAME', 'Specifies the environment to run this delayed jobs under (test/development/production).') do
|
31
|
-
warn 'The -e/--environment option has been deprecated and has no effect. Use RAILS_ENV and see http://github.com/collectiveidea/delayed_job/issues/7'
|
32
|
-
end
|
33
30
|
opt.on('--pid-dir=DIR', 'Specifies an alternate directory in which to store the process ids.') do |dir|
|
34
31
|
@options[:pid_dir] = dir
|
35
32
|
end
|
@@ -39,7 +36,7 @@ module Cron
|
|
39
36
|
opt.on('-m', '--monitor', 'Start monitor process.') do
|
40
37
|
@options[:monitor] = true
|
41
38
|
end
|
42
|
-
opt.on('--exit-on-complete', 'Exit when no more jobs are available to run.
|
39
|
+
opt.on('--exit-on-complete', 'Exit when no more jobs are available to run.') do
|
43
40
|
@options[:exit_on_complete] = true
|
44
41
|
end
|
45
42
|
opt.on('--daemon-options a, b, c', Array, 'options to be passed through to daemons gem') do |daemon_options|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cron
|
4
|
+
#
|
5
|
+
# Take care of job metrics
|
6
|
+
#
|
7
|
+
class RecordDelayedJobMetrics < Job
|
8
|
+
cron_tab_entry :daily
|
9
|
+
|
10
|
+
#
|
11
|
+
# Main driver method
|
12
|
+
#
|
13
|
+
def execute
|
14
|
+
Delayed::Jobs::Run.each do |run|
|
15
|
+
metric = Delayed::Jobs::Metric.find_or_create_by! name: run.name
|
16
|
+
metric.set count: metric.count + 1,
|
17
|
+
total: run.duration + metric.total,
|
18
|
+
max: [metric.max, run.duration].max,
|
19
|
+
min: [metric.min, run.duration].min,
|
20
|
+
last_run_at: [run.locked_at, metric.last_run_at].compact.max
|
21
|
+
run.destroy!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|