web47core 2.0.0 → 3.0.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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +111 -41
  3. data/app/controllers/status_controller.rb +15 -4
  4. data/app/helpers/core_form_helper.rb +6 -6
  5. data/app/helpers/core_helper.rb +1 -1
  6. data/app/helpers/core_link_helper.rb +47 -8
  7. data/app/helpers/core_nav_bar_helper.rb +5 -4
  8. data/app/helpers/core_table_helper.rb +80 -0
  9. data/app/helpers/model_modal_helper.rb +3 -3
  10. data/app/views/common/_create_actions.html.haml +12 -0
  11. data/app/views/common/_update_actions.html.haml +10 -0
  12. data/app/views/cron/_edit.html.haml +15 -17
  13. data/app/views/cron/_index.html.haml +74 -67
  14. data/app/views/delayed_job_metrics/_index.html.haml +27 -0
  15. data/app/views/delayed_job_metrics/index.html.haml +1 -0
  16. data/app/views/delayed_job_workers/_index.html.haml +27 -0
  17. data/app/views/delayed_job_workers/index.html.haml +1 -0
  18. data/app/views/delayed_jobs/_index.html.haml +47 -52
  19. data/app/views/delayed_jobs/_show.html.haml +15 -13
  20. data/app/views/system_configurations/_edit.html.haml +14 -9
  21. data/app/views/system_configurations/_show.html.haml +18 -12
  22. data/config/brakeman.ignore +26 -0
  23. data/config/brakeman.yml +2 -0
  24. data/config/locales/en.yml +21 -3
  25. data/lib/app/controllers/concerns/core_delayed_job_metrics_controller.rb +35 -0
  26. data/lib/app/controllers/concerns/core_delayed_job_workers_controller.rb +35 -0
  27. data/lib/app/controllers/concerns/core_delayed_jobs_controller.rb +2 -3
  28. data/lib/app/jobs/application_job.rb +0 -1
  29. data/lib/app/jobs/cron/command.rb +1 -4
  30. data/lib/app/jobs/cron/record_delayed_job_metrics.rb +25 -0
  31. data/lib/app/jobs/cron/restart_orphaned_delayed_jobs.rb +44 -0
  32. data/lib/app/jobs/cron/server.rb +32 -15
  33. data/lib/app/jobs/cron/switchboard_sync_configuration.rb +2 -0
  34. data/lib/app/jobs/cron/switchboard_sync_models.rb +2 -0
  35. data/lib/app/jobs/cron/tab.rb +1 -1
  36. data/lib/app/jobs/cron/trim_collection.rb +1 -1
  37. data/lib/app/jobs/cron/trim_command_jobs.rb +28 -0
  38. data/lib/app/jobs/cron/trim_delayed_job_metrics.rb +29 -0
  39. data/lib/app/jobs/cron/trim_delayed_job_workers.rb +39 -0
  40. data/lib/app/jobs/cron/trim_failed_delayed_jobs.rb +2 -0
  41. data/lib/app/models/api_token.rb +9 -0
  42. data/lib/app/models/command_job.rb +375 -0
  43. data/lib/app/models/command_job_log.rb +33 -0
  44. data/lib/app/models/concerns/api_tokenable.rb +38 -0
  45. data/lib/app/models/concerns/aws_configuration.rb +41 -0
  46. data/lib/app/models/concerns/cdn_url.rb +7 -0
  47. data/lib/app/models/concerns/core_smtp_configuration.rb +65 -0
  48. data/lib/app/models/concerns/core_system_configuration.rb +21 -204
  49. data/lib/app/models/concerns/delayed_job_configuration.rb +24 -0
  50. data/lib/app/models/concerns/email_able.rb +7 -3
  51. data/lib/app/models/concerns/search_able.rb +16 -0
  52. data/lib/app/models/concerns/server_process_able.rb +69 -0
  53. data/lib/app/models/concerns/slack_configuration.rb +38 -0
  54. data/lib/app/models/concerns/standard_model.rb +8 -9
  55. data/lib/app/models/concerns/switchboard_configuration.rb +43 -0
  56. data/lib/app/models/concerns/twilio_configuration.rb +37 -0
  57. data/lib/app/models/concerns/zendesk_configuration.rb +92 -0
  58. data/lib/app/models/{delayed_job.rb → delayed/backend/delayed_job.rb} +41 -0
  59. data/lib/app/models/delayed/jobs/metric.rb +61 -0
  60. data/lib/app/models/delayed/jobs/run.rb +40 -0
  61. data/lib/app/models/delayed/jobs/worker.rb +43 -0
  62. data/lib/app/models/delayed/plugins/time_keeper.rb +33 -0
  63. data/lib/app/models/delayed/worker.rb +24 -0
  64. data/lib/app/models/email_notification.rb +2 -1
  65. data/lib/app/models/email_template.rb +5 -6
  66. data/lib/app/models/notification.rb +12 -2
  67. data/lib/app/models/notification_template.rb +1 -1
  68. data/lib/app/models/sms_notification.rb +9 -6
  69. data/lib/app/models/smtp_configuration.rb +3 -3
  70. data/lib/app/models/template.rb +12 -12
  71. data/lib/web47core/version.rb +1 -1
  72. data/lib/web47core.rb +35 -9
  73. metadata +147 -216
@@ -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
- %ul.tabs#stack_cron
6
- %li.tab.col.s6
7
- %a{href: '#cron_job_servers'}='Cron Servers'
8
- %li.tab.col.s6
9
- %a{href: '#job_cron_tabs'}='Cron Jobs'
10
- .row
11
- .col.s12
12
- #cron_job_servers.col.s12{data: {cache: 'stack_cron'}}
13
- %table.highlight.bordered.extended
14
- %thead
15
- %tr
16
- %th.center-align= t('.host')
17
- %th.center-align= t('.state')
18
- %th.center-align= t('.last_check_in_at')
19
- %th.center-align= t('.actions')
20
- %tbody.white-text
21
- - Cron::Server.all.each do |server|
22
- %tr{class: server.alive? ? 'green lighten-1' : 'red lighten-1'}
23
- %td="#{server.host_name}:#{server.pid}"
24
- %td.center-align
25
- - if server.primary?
26
- %i.material-icons.white-text
27
- grade
28
- - else
29
-  
30
- %td=l(server.last_check_in_at, format: :medium)
31
- %td.center-align
32
- - if can? :manage, server
33
- .actions
34
- - if server.primary?
35
- = action_link_tag(can?(:manage, Cron::Server), model_action_path(server, :demote), icon_name: 'thumb_down' )
36
- - else
37
- = delete_link_tag(server, model_path(server))
38
- #job_cron_tabs.col.s12{data: {cache: 'stack_cron'}}
39
- %table.highlight.bordered.extended
40
- %thead
41
- %tr
42
- %th=t('.name')
43
- %th=t('.last_run_at')
44
- %th=t('.min')
45
- %th=t('.hour')
46
- %th=t('.mday')
47
- %th=t('.month')
48
- %th=t('.wday')
49
- %th=t('.enabled')
50
- %th=t('.actions')
51
- %tbody
52
- - Cron::JobTab.matching_search_text(params[:search]).each do |cron_tab|
53
- %tr
54
- %td.name=cron_tab.name.humanize
55
- %td=current_user.local_time(cron_tab.last_run_at)
56
- %td=cron_tab.min
57
- %td=cron_tab.hour
58
- %td=cron_tab.mday
59
- %td=cron_tab.month
60
- %td=cron_tab.wday
61
- %td
62
- - if cron_tab.valid_environment?
63
- %i.material-icons.green-text
64
- check
65
- - else
66
- %nbsp
67
- %td.actions
68
- = edit_link_tag(cron_tab, edit_model_path(cron_tab))
69
- - if cron_tab.valid_environment?
70
- = replay_link_tag(cron_tab, model_action_path(cron_tab, :run_now), icon_name: 'directions_run', confirm: t('.confirm', name: cron_tab.name.humanize))
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
- - if can?(:manage, Delayed::Backend::Mongoid::Job)
3
- .fixed-action-btn.horizontal
4
- %a.btn-floating.btn-large{style: 'padding: 0;margin: 15px 15px' }
5
- %i.material-icons replay
6
- %ul
7
- %li
8
- %a.btn-floating.yellow{href: class_action_path(:destroy_all, failed_only:true),
9
- title: t('.destroy_all'),
10
- data: {confirm: t('.confirm_destroy_all')}}
11
- %i.material-icons
12
- delete
13
- %li
14
- %a.btn-floating.red{href: class_action_path(:destroy_all, failed_only:false),
15
- title: t('.destroy_all'),
16
- data: {confirm: t('.confirm_destroy_all')}}
17
- %i.material-icons
18
- delete
19
- %li
20
- %a.btn-floating.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
- %li
26
- %a.btn-floating.red{href: class_action_path(:resbumit_all, failed_only:false),
27
- title: t('.resubmit_all'),
28
- data: {confirm: t('.confirm_resubmit_all')}}
29
- %i.material-icons
30
- restore
31
- - if @delayed_jobs.blank?
32
- %h2.center-align.grey-text=t('.no_data_found')
33
- - else
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
- %td=current_user.local_time(delayed_job.created_at)
49
- %td.name=link_to(delayed_job.display_name, model_path(delayed_job))
50
- %td=delayed_job.priority
51
- %td=delayed_job.status_description
52
- %td.actions
53
- = replay_link_tag(delayed_job, model_action_path(delayed_job, :resubmit), confirm: 'Are you sure you want to restart this job?')
54
- = delete_link_tag(delayed_job, model_path(delayed_job))
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 t('.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
- .mod
9
- .mod-body.no-padding
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
- - if can? :manage, @delayed_job
54
- .row
55
- .col.s6.center-align
56
- = link_to "Delete", model_path(@delayed_job), class: 'button delete', method: :delete, data: {confirm: "Are you sure you want to delete this job?"}
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 t('.title', name: SystemConfiguration.environment.titleize)
2
- .container
3
- %form{action: index_path, method: :post}
4
- %input{type: :hidden, value: form_authenticity_token, name: 'authenticity_token'}
5
- %input{type: :hidden, name: '_method', value: 'put'}
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
- = form_text_field(@system_configuration, :switchboard_base_url, classes: %w[s12 m4])
8
- = form_text_field(@system_configuration, :switchboard_stack_id, classes: %w[s12 m4])
9
- = form_password(@system_configuration, :switchboard_stack_api_token, classes: %w[s12 m4])
10
- = render '/common/form_actions', form_cancel_path: index_path
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 t('.title', name: SystemConfiguration.environment.titleize)
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
- %table.highlight.striped.extended
7
- %thead
8
- %tr
9
- %th.center-align=t('.field_header')
10
- %th.center-align=t('.value_header')
11
- %tbody
12
- - SystemConfiguration.allowed_param_names.sort.each do |field|
13
- %tr
14
- %td.right-align=field.titleize
15
- %td.left-align=mask_system_configuration(field)
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
+ }
@@ -0,0 +1,2 @@
1
+ ---
2
+ :ignore_file: config/brakeman.ignore
@@ -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
- .order_by(locked_by: :desc, priority: :asc, run_at: :asc)
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
  #
@@ -13,7 +13,6 @@ class ApplicationJob < ActiveJob::Base
13
13
  # Standard approach to running jobs
14
14
  #
15
15
  def perform(payload = {})
16
- Rails.cache.reconnect
17
16
  @started_at = Time.now.utc
18
17
  @payload = payload
19
18
  parse_payload
@@ -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. This will exit if all jobs are scheduled to run in the future.') do
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