barbeque 0.0.1 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/Rakefile +2 -6
  4. data/app/assets/javascripts/barbeque/application.js +5 -0
  5. data/app/assets/javascripts/barbeque/job_definitions.coffee +10 -0
  6. data/app/assets/stylesheets/barbeque/application.scss +7 -0
  7. data/app/assets/stylesheets/barbeque/common.scss +22 -0
  8. data/app/assets/stylesheets/barbeque/job_definitions.scss +21 -0
  9. data/app/controllers/barbeque/api/application_controller.rb +22 -0
  10. data/app/controllers/barbeque/api/job_executions_controller.rb +35 -0
  11. data/app/controllers/barbeque/api/job_retries_controller.rb +28 -0
  12. data/app/controllers/barbeque/api/revision_locks_controller.rb +34 -0
  13. data/app/controllers/barbeque/apps_controller.rb +43 -0
  14. data/app/controllers/barbeque/job_definitions_controller.rb +86 -0
  15. data/app/controllers/barbeque/job_executions_controller.rb +19 -0
  16. data/app/controllers/barbeque/job_queues_controller.rb +59 -0
  17. data/app/controllers/barbeque/job_retries_controller.rb +10 -0
  18. data/app/helpers/barbeque/job_definitions_helper.rb +14 -0
  19. data/app/helpers/barbeque/job_executions_helper.rb +18 -0
  20. data/app/models/{api → barbeque/api}/application_resource.rb +3 -1
  21. data/app/models/{api → barbeque/api}/job_execution_resource.rb +1 -1
  22. data/app/models/{api → barbeque/api}/job_retry_resource.rb +1 -1
  23. data/app/models/barbeque/api/revision_lock_resource.rb +7 -0
  24. data/app/models/{app.rb → barbeque/app.rb} +1 -1
  25. data/app/models/barbeque/job_definition.rb +26 -0
  26. data/app/models/{job_execution.rb → barbeque/job_execution.rb} +7 -4
  27. data/app/models/{job_queue.rb → barbeque/job_queue.rb} +1 -1
  28. data/app/models/{job_retry.rb → barbeque/job_retry.rb} +7 -2
  29. data/app/models/{slack_notification.rb → barbeque/slack_notification.rb} +1 -1
  30. data/app/services/barbeque/message_enqueuing_service.rb +41 -0
  31. data/app/services/barbeque/message_retrying_service.rb +32 -0
  32. data/app/views/barbeque/apps/_form.html.haml +34 -0
  33. data/app/views/barbeque/apps/edit.html.haml +3 -0
  34. data/app/views/barbeque/apps/index.html.haml +24 -0
  35. data/app/views/barbeque/apps/new.html.haml +3 -0
  36. data/app/views/barbeque/apps/show.html.haml +47 -0
  37. data/app/views/barbeque/job_definitions/_form.html.haml +45 -0
  38. data/app/views/barbeque/job_definitions/_slack_notification_field.html.haml +35 -0
  39. data/app/views/barbeque/job_definitions/edit.html.haml +3 -0
  40. data/app/views/barbeque/job_definitions/index.html.haml +24 -0
  41. data/app/views/barbeque/job_definitions/new.html.haml +3 -0
  42. data/app/views/barbeque/job_definitions/show.html.haml +90 -0
  43. data/app/views/barbeque/job_definitions/stats.html.haml +52 -0
  44. data/app/views/barbeque/job_executions/show.html.haml +92 -0
  45. data/app/views/barbeque/job_queues/_form.html.haml +29 -0
  46. data/app/views/barbeque/job_queues/edit.html.haml +3 -0
  47. data/app/views/barbeque/job_queues/index.html.haml +22 -0
  48. data/app/views/barbeque/job_queues/new.html.haml +3 -0
  49. data/app/views/barbeque/job_queues/show.html.haml +22 -0
  50. data/app/views/barbeque/job_retries/show.html.haml +59 -0
  51. data/app/views/layouts/barbeque/_header.html.haml +10 -0
  52. data/app/views/layouts/barbeque/_sidebar.html.haml +16 -0
  53. data/app/views/layouts/barbeque/application.html.haml +24 -0
  54. data/app/views/layouts/barbeque/apps.html.haml +6 -0
  55. data/app/views/layouts/barbeque/job_definitions.html.haml +6 -0
  56. data/app/views/layouts/barbeque/job_executions.html.haml +5 -0
  57. data/app/views/layouts/barbeque/job_queues.html.haml +6 -0
  58. data/config/initializers/garage.rb +4 -0
  59. data/config/routes.rb +32 -0
  60. data/db/migrate/20160829023237_prefix_barbeque_to_tables.rb +10 -0
  61. data/lib/barbeque.rb +3 -5
  62. data/lib/barbeque/configuration.rb +19 -0
  63. data/lib/barbeque/docker_image.rb +20 -0
  64. data/lib/barbeque/engine.rb +11 -0
  65. data/lib/barbeque/execution_log.rb +51 -0
  66. data/lib/barbeque/message.rb +28 -0
  67. data/lib/barbeque/message/base.rb +29 -0
  68. data/lib/barbeque/message/invalid_message.rb +11 -0
  69. data/lib/barbeque/message/job_execution.rb +20 -0
  70. data/lib/barbeque/message/job_retry.rb +16 -0
  71. data/lib/barbeque/message_handler.rb +8 -0
  72. data/lib/barbeque/message_handler/job_execution.rb +86 -0
  73. data/lib/barbeque/message_handler/job_retry.rb +83 -0
  74. data/lib/barbeque/message_queue.rb +66 -0
  75. data/lib/barbeque/runner.rb +12 -0
  76. data/lib/barbeque/runner/docker.rb +34 -0
  77. data/lib/barbeque/slack_client.rb +48 -0
  78. data/lib/barbeque/version.rb +1 -1
  79. data/lib/barbeque/worker.rb +58 -0
  80. data/lib/tasks/barbeque_tasks.rake +9 -4
  81. metadata +272 -18
  82. data/app/assets/stylesheets/barbeque/application.css +0 -15
  83. data/app/models/application_record.rb +0 -3
  84. data/app/models/job_definition.rb +0 -14
  85. data/app/views/layouts/barbeque/application.html.erb +0 -14
@@ -0,0 +1,3 @@
1
+ = render 'form'
2
+
3
+ = link_to 'Back', job_definitions_path
@@ -0,0 +1,24 @@
1
+ .box.box-primary
2
+ .box-header
3
+ %h3.box-title.with_padding
4
+ All Job Definitions
5
+ = link_to new_job_definition_path, class: 'btn btn-primary pull-right' do
6
+ New Job Definition
7
+
8
+ .box-body
9
+ %table.table.table-bordered
10
+ %thead
11
+ %tr
12
+ %th Application
13
+ %th Job
14
+ %th Description
15
+ %th
16
+
17
+ %tbody
18
+ - @job_definitions.each do |job_definition|
19
+ %tr
20
+ %td= job_definition.app.name
21
+ %td= job_definition.job
22
+ %td= job_definition.description
23
+ %td
24
+ = link_to 'View Details', job_definition, class: 'btn btn-default btn-sm'
@@ -0,0 +1,3 @@
1
+ = render 'form'
2
+
3
+ = link_to 'Back', job_definitions_path
@@ -0,0 +1,90 @@
1
+ .row
2
+ .col-sm-7
3
+ .box.box-primary
4
+ .box-header
5
+ %h3.box-title.with_padding
6
+ Job Definition Details
7
+
8
+ .box-body
9
+ %p#notice= notice
10
+
11
+ %table.table.table-bordered
12
+ %tbody
13
+ %tr
14
+ %th Application
15
+ %td= link_to(@job_definition.app.name, app_path(@job_definition.app.id))
16
+ %tr
17
+ %th Job
18
+ %td= @job_definition.job
19
+ %tr
20
+ %th Command
21
+ %td= Shellwords.join(@job_definition.command)
22
+ %tr
23
+ %th Description
24
+ %td= @job_definition.description
25
+ %tr
26
+ %th Slack Notification
27
+ %td
28
+ - if @job_definition.slack_notification
29
+ Yes (#{@job_definition.slack_notification.channel})
30
+ - else
31
+ No
32
+
33
+ = link_to 'Edit', edit_job_definition_path(@job_definition), class: 'btn btn-primary'
34
+ = link_to 'Destroy', job_definition_path(@job_definition),
35
+ class: 'btn', method: :delete, data: { confirm: 'Are you sure to delete job definition?' }
36
+
37
+ .col-sm-5
38
+ .box.box-primary
39
+ .box-header
40
+ %h3.box-title.with_padding
41
+ Job Executions
42
+
43
+ .box-body
44
+ - if @job_executions.present?
45
+ .row
46
+ .col-xs-2
47
+ = link_to(job_definition_stats_path(@job_definition), class: 'btn btn-default btn-block') do
48
+ %i.fa.fa-line-chart
49
+ Statistics
50
+ %table.table.table-bordered
51
+ %thead
52
+ %tr
53
+ %th ID
54
+ %th Status
55
+ %th Started At
56
+ %th Elapsed Time
57
+ %th
58
+ %tbody
59
+ - @job_executions.each do |job_execution|
60
+ %tr
61
+ %td= job_execution.id
62
+ %td= status_label(job_execution.status)
63
+ %td= l(job_execution.created_at, format: :short)
64
+ %td= distance_of_time(job_execution.created_at, job_execution.finished_at)
65
+ %td
66
+ .btn-group
67
+ = link_to job_execution_path(job_execution), class: 'btn btn-default btn-sm btn-flat' do
68
+ %i.fa.fa-chevron-right
69
+ Details
70
+ - if job_execution.failed?
71
+ = link_to job_execution_retry_path(job_execution), method: :post, class: 'btn btn-default btn-sm btn-flat',
72
+ data: { disable_with: 'retrying...', confirm: "Are you sure to retry #{@job_definition.job} ##{job_execution.id}?" } do
73
+ %i.fa.fa-refresh
74
+ Retry
75
+ .row
76
+ .col-xs-4
77
+ = link_to url_for(page: @job_executions.prev_page),
78
+ class: "btn btn-default btn-sm btn-block #{'disabled' unless @job_executions.prev_page}" do
79
+ %i.fa.fa-angle-left
80
+ New
81
+ .col-xs-4.col-xs-offset-4
82
+ = link_to url_for(page: @job_executions.next_page),
83
+ class: "btn btn-default btn-sm btn-block #{'disabled' unless @job_executions.next_page}" do
84
+ Old
85
+ %i.fa.fa-angle-right
86
+
87
+ - else
88
+ No job execution
89
+
90
+ = link_to 'Back', job_definitions_path
@@ -0,0 +1,52 @@
1
+ .row
2
+ .col-sm-12
3
+ .box.box-primary
4
+ .box-header
5
+ %h3.box-title.with_padding
6
+ %i.fa.fa-line-chart
7
+ Execution statistics for #{@days} #{'day'.pluralize(@days)}
8
+ .box-body
9
+ = form_tag(job_definition_stats_path(@job_definition), method: :get, class: 'form-inline') do
10
+ .form-group
11
+ .input-group
12
+ = text_field_tag :days, @days, class: 'form-control'
13
+ .input-group-addon
14
+ days
15
+ = submit_tag 'Go', class: 'btn btn-default'
16
+ #execution-count-chart
17
+ #execution-time-chart
18
+
19
+ = link_to 'Back', job_definition_path(@job_definition)
20
+
21
+ :coffee
22
+ jQuery(($) ->
23
+ $.getJSON('#{job_definition_execution_stats_path(@job_definition, days: @days)}').then((stats) ->
24
+ countDiv = document.getElementById('execution-count-chart')
25
+ timeDiv = document.getElementById('execution-time-chart')
26
+
27
+ date_hours = stats.map((stat) -> stat.date_hour)
28
+ counts = stats.map((stat) -> stat.count)
29
+ avg_times = stats.map((stat) -> stat.avg_time)
30
+
31
+ Plotly.plot(countDiv, [
32
+ {
33
+ type: 'scatter',
34
+ name: 'Number of executions',
35
+ x: date_hours,
36
+ y: counts,
37
+ },
38
+ ], {
39
+ title: 'Number of executions (hourly)',
40
+ })
41
+ Plotly.plot(timeDiv, [
42
+ {
43
+ type: 'scatter',
44
+ name: 'Average execution time',
45
+ x: date_hours,
46
+ y: avg_times,
47
+ },
48
+ ], {
49
+ title: 'Average execution time (hourly)',
50
+ })
51
+ )
52
+ )
@@ -0,0 +1,92 @@
1
+ .row
2
+ .col-sm-7
3
+ .box.box-primary
4
+ .box-header
5
+ .row
6
+ .col-md-10
7
+ %h3.box-title.with_padding
8
+ \##{@job_execution.id} of
9
+ = link_to @job_execution.job_definition do
10
+ #{@job_execution.job_definition.job}
11
+ - if @job_execution.failed?
12
+ .col-md-2
13
+ = link_to job_execution_retry_path(@job_execution), method: :post, class: 'btn btn-default btn-block pull-right',
14
+ data: { disable_with: 'retrying...', confirm: "Are you sure to retry #{@job_execution.job_definition.job} ##{@job_execution.id}?" } do
15
+ Retry
16
+
17
+ .box-body
18
+ %table.table.table-bordered
19
+ %tbody
20
+ %tr
21
+ %th Execution ID
22
+ %td= @job_execution.id
23
+ %tr
24
+ %th Status
25
+ %td= status_label(@job_execution.status)
26
+ %tr
27
+ %th Created at
28
+ %td= @job_execution.created_at
29
+ %tr
30
+ %th Finished at
31
+ %td= @job_execution.finished_at
32
+ %tr
33
+ %th Elapsed time
34
+ %td= distance_of_time(@job_execution.created_at, @job_execution.finished_at)
35
+ %tr
36
+ %th Message ID
37
+ %td= @job_execution.message_id
38
+ %tr
39
+ %th Message
40
+ %td
41
+ %code= @message
42
+ .col-sm-5
43
+ .box.box-primary
44
+ .box-header
45
+ %h3.box-title.with_padding
46
+ Retries
47
+
48
+ .box-body
49
+ - if @job_execution.job_retries.present?
50
+ %table.table.table-bordered
51
+ %thead
52
+ %tr
53
+ %th ID
54
+ %th Status
55
+ %th Started At
56
+ %th Elapsed Time
57
+ %th
58
+ %tbody
59
+ - @job_execution.job_retries.each do |job_retry|
60
+ %tr
61
+ %td= job_retry.id
62
+ %td= status_label(job_retry.status)
63
+ %td= l(job_retry.created_at, format: :short)
64
+ %td= distance_of_time(job_retry.created_at, job_retry.finished_at)
65
+ %td
66
+ .btn-group
67
+ = link_to job_execution_job_retry_path(@job_execution, job_retry), class: 'btn btn-default btn-sm btn-flat' do
68
+ %i.fa.fa-chevron-right
69
+ Details
70
+ - else
71
+ Not retried.
72
+
73
+ .row
74
+ .col-sm-6
75
+ .box.box-primary
76
+ .box-header
77
+ %h3.box-title.with_padding
78
+ Stdout
79
+
80
+ .box-body
81
+ %pre= @stdout
82
+
83
+ .col-sm-6
84
+ .box.box-primary
85
+ .box-header
86
+ %h3.box-title.with_padding
87
+ Stderr
88
+
89
+ .box-body
90
+ %pre= @stderr
91
+
92
+ = link_to 'Back', job_definition_path(@job_execution.job_definition)
@@ -0,0 +1,29 @@
1
+ .box.box-primary
2
+ .box-header
3
+ %h3.box-title.with_padding
4
+ #{action_name.capitalize} Job Queue
5
+
6
+ .box-body
7
+ = form_for @job_queue do |f|
8
+ - if @job_queue.errors.any?
9
+ %strong #{pluralize(@job_queue.errors.count, 'error')} prohibited this job_queue from being saved:
10
+ %ul
11
+ - @job_queue.errors.full_messages.each do |msg|
12
+ %li= msg
13
+
14
+ .row.form-group
15
+ .col-md-4
16
+ = f.label :name
17
+ - if @job_queue.persisted?
18
+ -# Name can't be changed after it's created.
19
+ .job_queue_name= @job_queue.name
20
+ - else
21
+ = f.text_field :name, class: 'form-control'
22
+
23
+ .row.form-group
24
+ .col-md-8
25
+ = f.label :description
26
+ = f.text_area :description, class: 'form-control', rows: 10
27
+
28
+ .form-group
29
+ = f.submit 'Save', class: 'btn btn-primary'
@@ -0,0 +1,3 @@
1
+ = render 'form'
2
+
3
+ = link_to 'Back', job_queues_path
@@ -0,0 +1,22 @@
1
+ .box.box-primary
2
+ .box-header
3
+ %h3.box-title.with_padding
4
+ All Job Queues
5
+ = link_to new_job_queue_path, class: 'btn btn-primary pull-right' do
6
+ New Job Queue
7
+
8
+ .box-body
9
+ %table.table.table-bordered
10
+ %thead
11
+ %tr
12
+ %th Name
13
+ %th Description
14
+ %th
15
+
16
+ %tbody
17
+ - @job_queues.each do |job_queue|
18
+ %tr
19
+ %td= job_queue.name
20
+ %td= job_queue.description
21
+ %td
22
+ = link_to 'View Details', job_queue, class: 'btn btn-default btn-sm'
@@ -0,0 +1,3 @@
1
+ = render 'form'
2
+
3
+ = link_to 'Back', job_queues_path
@@ -0,0 +1,22 @@
1
+ .box.box-primary
2
+ .box-header
3
+ %h3.box-title.with_padding
4
+ Job Queue Details
5
+
6
+ .box-body
7
+ %p#notice= notice
8
+
9
+ %table.table.table-bordered
10
+ %tbody
11
+ %tr
12
+ %th Name
13
+ %td= @job_queue.name
14
+ %tr
15
+ %th Description
16
+ %td= @job_queue.description
17
+
18
+ = link_to 'Edit', edit_job_queue_path(@job_queue), class: 'btn btn-primary'
19
+ = link_to 'Destroy', job_queue_path(@job_queue),
20
+ class: 'btn', method: :delete, data: { confirm: 'Are you sure to delete queue?' }
21
+
22
+ = link_to 'Back', job_queues_path
@@ -0,0 +1,59 @@
1
+ .row
2
+ .col-sm-12
3
+ .box.box-primary
4
+ .box-header
5
+ .row
6
+ .col-md-10
7
+ %h3.box-title.with_padding
8
+ Retry ##{@job_retry.id} of
9
+ = link_to @job_retry.job_definition do
10
+ #{@job_retry.job_definition.job}
11
+ = link_to @job_execution do
12
+ \##{@job_execution.id}
13
+
14
+ .box-body
15
+ %table.table.table-bordered
16
+ %tbody
17
+ %tr
18
+ %th Execution ID
19
+ %td= @job_retry.id
20
+ %tr
21
+ %th Status
22
+ %td= status_label(@job_retry.status)
23
+ %tr
24
+ %th Created at
25
+ %td= @job_retry.created_at
26
+ %tr
27
+ %th Finished at
28
+ %td= @job_retry.finished_at
29
+ %tr
30
+ %th Elapsed time
31
+ %td= distance_of_time(@job_retry.created_at, @job_retry.finished_at)
32
+ %tr
33
+ %th Message ID
34
+ %td= @job_retry.message_id
35
+ %tr
36
+ %th Message
37
+ %td
38
+ %code= @message
39
+
40
+ .row
41
+ .col-sm-6
42
+ .box.box-primary
43
+ .box-header
44
+ %h3.box-title.with_padding
45
+ Stdout
46
+
47
+ .box-body
48
+ %pre= @stdout
49
+
50
+ .col-sm-6
51
+ .box.box-primary
52
+ .box-header
53
+ %h3.box-title.with_padding
54
+ Stderr
55
+
56
+ .box-body
57
+ %pre= @stderr
58
+
59
+ = link_to 'Back', job_execution_path(@job_execution)
@@ -0,0 +1,10 @@
1
+ %header.main-header
2
+ %a.logo{ href: '/' }
3
+ %span.logo-mini
4
+ %b> BBQ
5
+ %span.logo-lg
6
+ %b> Barbeque
7
+
8
+ %nav.navbar.navbar-static-top{ role: 'navigation' }
9
+ %a.sidebar-toggle{ 'data-toggle': 'offcanvas', href: '#', role: 'button' }
10
+ %span.sr-only Toggle navigation
@@ -0,0 +1,16 @@
1
+ %aside.main-sidebar
2
+ %section.sidebar
3
+ %ul.sidebar-menu
4
+ %li.header Menu
5
+ %li{ class: ('active' if controller_path == 'apps') }
6
+ = link_to root_path do
7
+ %i.fa.fa-users
8
+ %span Applications
9
+ %li{ class: ('active' if controller_path == 'job_definitions') }
10
+ = link_to job_definitions_path do
11
+ %i.fa.fa-tasks
12
+ %span Job Definitions
13
+ %li{ class: ('active' if controller_path == 'job_queues') }
14
+ = link_to job_queues_path do
15
+ %i.fa.fa-cubes
16
+ %span Queues