rocketjob_mission_control 2.1.1 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/assets/stylesheets/rocket_job_mission_control/callout.scss +1 -1
- data/app/assets/stylesheets/rocket_job_mission_control/worker_processes.scss +2 -2
- data/app/controllers/rocket_job_mission_control/active_workers_controller.rb +15 -0
- data/app/controllers/rocket_job_mission_control/dirmon_entries/index_filters_controller.rb +8 -13
- data/app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb +3 -14
- data/app/controllers/rocket_job_mission_control/jobs/failures_controller.rb +6 -11
- data/app/controllers/rocket_job_mission_control/jobs/index_filters_controller.rb +35 -14
- data/app/controllers/rocket_job_mission_control/jobs_controller.rb +12 -15
- data/app/controllers/rocket_job_mission_control/servers/index_filters_controller.rb +49 -0
- data/app/controllers/rocket_job_mission_control/servers_controller.rb +93 -0
- data/app/datatables/rocket_job_mission_control/abstract_datatable.rb +62 -0
- data/app/datatables/rocket_job_mission_control/active_workers_datatable.rb +47 -0
- data/app/datatables/rocket_job_mission_control/completed_jobs_datatable.rb +1 -1
- data/app/datatables/rocket_job_mission_control/dirmon_entries_datatable.rb +10 -72
- data/app/datatables/rocket_job_mission_control/interrupted_jobs_datatable.rb +1 -1
- data/app/datatables/rocket_job_mission_control/jobs_datatable.rb +16 -91
- data/app/datatables/rocket_job_mission_control/queued_jobs_datatable.rb +1 -1
- data/app/datatables/rocket_job_mission_control/running_jobs_datatable.rb +23 -12
- data/app/datatables/rocket_job_mission_control/scheduled_jobs_datatable.rb +1 -1
- data/app/datatables/rocket_job_mission_control/servers_datatable.rb +67 -0
- data/app/helpers/rocket_job_mission_control/{workers_helper.rb → servers_helper.rb} +9 -9
- data/app/models/job_failures.rb +3 -16
- data/app/models/rocket_job_mission_control/query.rb +51 -0
- data/app/views/layouts/rocket_job_mission_control/partials/_header.html.haml +3 -3
- data/app/views/layouts/rocket_job_mission_control/partials/_sidebar.html.haml +2 -2
- data/app/views/rocket_job_mission_control/{active_processes → active_workers}/index.html.haml +3 -3
- data/app/views/rocket_job_mission_control/dirmon_entries/_properties.html.haml +7 -18
- data/app/views/rocket_job_mission_control/dirmon_entries/_status.html.haml +0 -5
- data/app/views/rocket_job_mission_control/dirmon_entries/show.html.haml +4 -3
- data/app/views/rocket_job_mission_control/jobs/_status.html.haml +22 -17
- data/app/views/rocket_job_mission_control/jobs/edit.html.haml +1 -1
- data/app/views/rocket_job_mission_control/jobs/exceptions.html.haml +29 -0
- data/app/views/rocket_job_mission_control/jobs/failures/index.html.haml +7 -7
- data/app/views/rocket_job_mission_control/jobs/show.html.haml +23 -11
- data/app/views/rocket_job_mission_control/servers/_actions.html.haml +9 -0
- data/app/views/rocket_job_mission_control/servers/_sidebar.html.haml +20 -0
- data/app/views/rocket_job_mission_control/{workers → servers}/index.html.haml +9 -9
- data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/paused.html.haml +8 -8
- data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/running.html.haml +8 -8
- data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/starting.html.haml +8 -8
- data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/stopping.html.haml +8 -8
- data/config/locales/en.yml +2 -2
- data/config/routes.rb +7 -6
- data/lib/rocket_job_mission_control/engine.rb +0 -12
- data/lib/rocket_job_mission_control/version.rb +1 -1
- data/spec/controllers/dirmon_entries/index_filters_controller_spec.rb +2 -4
- data/spec/controllers/dirmon_entries_controller_spec.rb +15 -72
- data/spec/controllers/jobs/index_filters_controller_spec.rb +1 -1
- data/spec/controllers/workers/index_filters_controller_spec.rb +9 -9
- data/spec/controllers/workers_controller_spec.rb +47 -47
- data/spec/dummy/config/mongoid.yml +88 -0
- data/spec/dummy/config/symmetric-encryption.yml +8 -0
- data/spec/dummy/log/test.log +89072 -0
- data/spec/helpers/servers_helper_spec.rb +16 -0
- data/spec/spec_helper.rb +3 -0
- metadata +31 -45
- data/app/controllers/rocket_job_mission_control/active_processes_controller.rb +0 -27
- data/app/controllers/rocket_job_mission_control/workers/index_filters_controller.rb +0 -50
- data/app/controllers/rocket_job_mission_control/workers_controller.rb +0 -93
- data/app/datatables/rocket_job_mission_control/active_processes_datatable.rb +0 -79
- data/app/datatables/rocket_job_mission_control/workers_datatable.rb +0 -127
- data/app/interactors/rocket_job_mission_control/dirmon_entries/search.rb +0 -19
- data/app/interactors/rocket_job_mission_control/jobs/search.rb +0 -19
- data/app/interactors/rocket_job_mission_control/workers/search.rb +0 -19
- data/app/views/rocket_job_mission_control/workers/_actions.html.haml +0 -9
- data/app/views/rocket_job_mission_control/workers/_sidebar.html.haml +0 -20
- data/spec/dummy/config/mongo.yml +0 -15
- data/spec/helpers/workers_helper_spec.rb +0 -16
- data/spec/interactors/jobs/search_spec.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70e693d49e4ca57ddb518fbd75c3b66facbe134d
|
4
|
+
data.tar.gz: f2d480f5f2f19fdb8106f5d258173b05b66e6d11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e040ed3c8d00608471dc4c55e07b4b28f17731ed07ab2c6309663993f91323e8f348816d4b2de37e9f9290ccc5c3bec7eda905227a76ac29bff082e4fc6abd4
|
7
|
+
data.tar.gz: f6871621fb675475d9733cd181c108a6d7ad3877b65a8a47128f68ef5b8eaaedb26859df81a511c4fb37a4487a4ca465339f5bb044b903736e95e84fa79d5367
|
data/README.md
CHANGED
@@ -24,10 +24,10 @@ Job Management
|
|
24
24
|
* Abort, or fail queued or running jobs
|
25
25
|
* Destroy a completed or aborted job
|
26
26
|
|
27
|
-
|
27
|
+
Server Management
|
28
28
|
|
29
|
-
* View running
|
30
|
-
* Stop
|
29
|
+
* View running servers
|
30
|
+
* Stop servers
|
31
31
|
|
32
32
|
Running Jobs
|
33
33
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RocketJobMissionControl
|
2
|
+
class ActiveWorkersController < RocketJobMissionControl::ApplicationController
|
3
|
+
# The list of workers actively processing jobs
|
4
|
+
# [Array[Array<server_name [String], job [RocketJob::Job], slice_id [String]]]
|
5
|
+
def index
|
6
|
+
@active_workers = RocketJob::ActiveWorker.all
|
7
|
+
@query = RocketJobMissionControl::Query.new(@active_workers, name: :asc)
|
8
|
+
|
9
|
+
respond_to do |format|
|
10
|
+
format.html
|
11
|
+
format.json { render(json: ActiveWorkersDatatable.new(view_context, @query)) }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,47 +1,42 @@
|
|
1
1
|
module RocketJobMissionControl
|
2
2
|
module DirmonEntries
|
3
3
|
class IndexFiltersController < RocketJobMissionControl::ApplicationController
|
4
|
-
before_filter :load_dirmon_entries
|
5
4
|
before_filter :show_sidebar
|
6
5
|
|
7
6
|
def pending
|
8
|
-
@
|
7
|
+
@query = RocketJobMissionControl::Query.new(RocketJob::DirmonEntry.pending, name: :asc)
|
9
8
|
respond_to do |format|
|
10
9
|
format.html
|
11
|
-
format.json { render(json: DirmonEntriesDatatable.new(view_context, @
|
10
|
+
format.json { render(json: DirmonEntriesDatatable.new(view_context, @query)) }
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
14
|
def enabled
|
16
|
-
@
|
15
|
+
@query = RocketJobMissionControl::Query.new(RocketJob::DirmonEntry.enabled, name: :asc)
|
17
16
|
respond_to do |format|
|
18
17
|
format.html
|
19
|
-
format.json { render(json: DirmonEntriesDatatable.new(view_context, @
|
18
|
+
format.json { render(json: DirmonEntriesDatatable.new(view_context, @query)) }
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
22
|
def failed
|
24
|
-
@
|
23
|
+
@query = RocketJobMissionControl::Query.new(RocketJob::DirmonEntry.failed, name: :asc)
|
25
24
|
respond_to do |format|
|
26
25
|
format.html
|
27
|
-
format.json { render(json: DirmonEntriesDatatable.new(view_context, @
|
26
|
+
format.json { render(json: DirmonEntriesDatatable.new(view_context, @query)) }
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
30
|
def disabled
|
32
|
-
@
|
31
|
+
@query = RocketJobMissionControl::Query.new(RocketJob::DirmonEntry.disabled, name: :asc)
|
33
32
|
respond_to do |format|
|
34
33
|
format.html
|
35
|
-
format.json { render(json: DirmonEntriesDatatable.new(view_context, @
|
34
|
+
format.json { render(json: DirmonEntriesDatatable.new(view_context, @query)) }
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
38
|
private
|
40
39
|
|
41
|
-
def load_dirmon_entries
|
42
|
-
@dirmons = RocketJob::DirmonEntry.where()
|
43
|
-
end
|
44
|
-
|
45
40
|
def show_sidebar
|
46
41
|
@dirmon_sidebar = true
|
47
42
|
end
|
@@ -6,10 +6,10 @@ module RocketJobMissionControl
|
|
6
6
|
before_filter :show_sidebar
|
7
7
|
|
8
8
|
def index
|
9
|
-
@
|
9
|
+
@query = RocketJobMissionControl::Query.new(RocketJob::DirmonEntry.all, name: :asc)
|
10
10
|
respond_to do |format|
|
11
11
|
format.html
|
12
|
-
format.json { render(json: DirmonEntriesDatatable.new(view_context, @
|
12
|
+
format.json { render(json: DirmonEntriesDatatable.new(view_context, @query)) }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -28,7 +28,6 @@ module RocketJobMissionControl
|
|
28
28
|
def create
|
29
29
|
@dirmon_entry = RocketJob::DirmonEntry.new(dirmon_params)
|
30
30
|
|
31
|
-
parse_and_assign_arguments
|
32
31
|
parse_and_assign_properties
|
33
32
|
|
34
33
|
if @dirmon_entry.errors.empty? && @dirmon_entry.save
|
@@ -51,7 +50,6 @@ module RocketJobMissionControl
|
|
51
50
|
|
52
51
|
def update
|
53
52
|
@dirmon_entry.attributes = dirmon_params
|
54
|
-
parse_and_assign_arguments
|
55
53
|
parse_and_assign_properties
|
56
54
|
if @dirmon_entry.errors.empty? && @dirmon_entry.save
|
57
55
|
flash[:success] = t(:success, scope: [:dirmon_entry, :update])
|
@@ -94,19 +92,10 @@ module RocketJobMissionControl
|
|
94
92
|
@dirmon_sidebar = true
|
95
93
|
end
|
96
94
|
|
97
|
-
def parse_and_assign_arguments
|
98
|
-
arguments = params[:rocket_job_dirmon_entry][:arguments] || []
|
99
|
-
@dirmon_entry.arguments = arguments.collect do |value|
|
100
|
-
cleansed = parse_array_element(value, :arguments, true)
|
101
|
-
@dirmon_entry.errors.add(:arguments, 'All arguments are mandatory') unless cleansed
|
102
|
-
cleansed
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
95
|
def parse_and_assign_properties
|
107
96
|
properties = params[:rocket_job_dirmon_entry].fetch(:properties, {})
|
108
97
|
properties.each_pair do |property, value|
|
109
|
-
if key = @dirmon_entry.job_class.
|
98
|
+
if key = @dirmon_entry.job_class.fields[property]
|
110
99
|
if key.type == Hash
|
111
100
|
begin
|
112
101
|
@dirmon_entry.properties[property] = JSON.parse(value)
|
@@ -3,26 +3,21 @@ module RocketJobMissionControl
|
|
3
3
|
class FailuresController < RocketJobMissionControl::ApplicationController
|
4
4
|
def index
|
5
5
|
job_failures = JobFailures.new(params[:job_id])
|
6
|
-
@job
|
7
|
-
|
8
|
-
if @job && @job.failed?
|
6
|
+
if @job = job_failures.job
|
9
7
|
@slice_errors = job_failures.list
|
10
8
|
|
11
9
|
if @slice_errors.present?
|
12
|
-
@error_type = params[:error_type] || @slice_errors.first
|
10
|
+
@error_type = params[:error_type] || @slice_errors.first.class_name
|
13
11
|
|
14
12
|
offset = params.fetch(:offset, 0).to_i
|
15
|
-
|
16
|
-
current_failure =
|
13
|
+
count = @slice_errors.find { |exception| exception.class_name == @error_type }.try!(:count) || 0
|
14
|
+
current_failure = job_failures.for_error(@error_type, offset)
|
15
|
+
@failure_exception = current_failure.try!(:exception)
|
17
16
|
|
18
17
|
@pagination = {
|
19
18
|
offset: offset,
|
20
|
-
total: (
|
19
|
+
total: (count - 1),
|
21
20
|
}
|
22
|
-
|
23
|
-
if current_failure.present?
|
24
|
-
@failure_exception = current_failure['exception']
|
25
|
-
end
|
26
21
|
else
|
27
22
|
flash[:notice] = t(:no_errors, scope: [:job, :failures])
|
28
23
|
end
|
@@ -3,59 +3,79 @@ module RocketJobMissionControl
|
|
3
3
|
class IndexFiltersController < RocketJobMissionControl::ApplicationController
|
4
4
|
before_filter :show_sidebar
|
5
5
|
|
6
|
+
COMMON_FIELDS = [:id, :_type, :description, :completed_at, :created_at, :started_at, :state].freeze
|
7
|
+
RUNNING_FIELDS = COMMON_FIELDS + [:record_count, :collect_output, :input_categories, :output_categories, :encrypt, :compress, :slice_size, :priority, :sub_state, :percent_complete].freeze
|
8
|
+
QUEUED_FIELDS = COMMON_FIELDS + [:run_at, :priority].freeze
|
9
|
+
SCHEDULED_FIELDS = COMMON_FIELDS + [:run_at, :cron_schedule].freeze
|
10
|
+
|
6
11
|
def running
|
7
|
-
@jobs
|
12
|
+
@jobs = RocketJob::Job.running.only(RUNNING_FIELDS)
|
13
|
+
@query = RocketJobMissionControl::Query.new(@jobs, started_at: :desc)
|
14
|
+
@query.display_columns = %w[_type description runs_in cron_schedule completed_at]
|
15
|
+
|
8
16
|
respond_to do |format|
|
9
17
|
format.html
|
10
|
-
format.json { render(json: RunningJobsDatatable.new(view_context, @
|
18
|
+
format.json { render(json: RunningJobsDatatable.new(view_context, @query)) }
|
11
19
|
end
|
12
20
|
end
|
13
21
|
|
14
22
|
def paused
|
15
|
-
@jobs
|
23
|
+
@jobs = RocketJob::Job.paused.only(COMMON_FIELDS)
|
24
|
+
@query = RocketJobMissionControl::Query.new(@jobs, completed_at: :desc)
|
25
|
+
@query.display_columns = %w[_type description completed_at]
|
16
26
|
respond_to do |format|
|
17
27
|
format.html
|
18
|
-
format.json { render(json: InterruptedJobsDatatable.new(view_context, @
|
28
|
+
format.json { render(json: InterruptedJobsDatatable.new(view_context, @query)) }
|
19
29
|
end
|
20
30
|
end
|
21
31
|
|
22
32
|
def completed
|
23
|
-
@jobs
|
33
|
+
@jobs = RocketJob::Job.completed.only(COMMON_FIELDS)
|
34
|
+
@query = RocketJobMissionControl::Query.new(@jobs, completed_at: :desc)
|
35
|
+
@query.display_columns = %w[_type description duration completed_at]
|
24
36
|
respond_to do |format|
|
25
37
|
format.html
|
26
|
-
format.json { render(json: CompletedJobsDatatable.new(view_context, @
|
38
|
+
format.json { render(json: CompletedJobsDatatable.new(view_context, @query)) }
|
27
39
|
end
|
28
40
|
end
|
29
41
|
|
30
42
|
def aborted
|
31
|
-
@jobs
|
43
|
+
@jobs = RocketJob::Job.aborted.only(COMMON_FIELDS)
|
44
|
+
@query = RocketJobMissionControl::Query.new(@jobs, completed_at: :desc)
|
45
|
+
@query.display_columns = %w[_type description completed_at]
|
32
46
|
respond_to do |format|
|
33
47
|
format.html
|
34
|
-
format.json { render(json: InterruptedJobsDatatable.new(view_context, @
|
48
|
+
format.json { render(json: InterruptedJobsDatatable.new(view_context, @query)) }
|
35
49
|
end
|
36
50
|
end
|
37
51
|
|
38
52
|
def failed
|
39
|
-
@jobs
|
53
|
+
@jobs = RocketJob::Job.failed.only(COMMON_FIELDS)
|
54
|
+
@query = RocketJobMissionControl::Query.new(@jobs, completed_at: :desc)
|
55
|
+
@query.display_columns = %w[_type description completed_at]
|
40
56
|
respond_to do |format|
|
41
57
|
format.html
|
42
|
-
format.json { render(json: InterruptedJobsDatatable.new(view_context, @
|
58
|
+
format.json { render(json: InterruptedJobsDatatable.new(view_context, @query)) }
|
43
59
|
end
|
44
60
|
end
|
45
61
|
|
46
62
|
def queued
|
47
|
-
@jobs
|
63
|
+
@jobs = RocketJob::Job.queued_now.only(QUEUED_FIELDS)
|
64
|
+
@query = RocketJobMissionControl::Query.new(@jobs, completed_at: :desc)
|
65
|
+
@query.display_columns = %w[_type description priority queued_for]
|
48
66
|
respond_to do |format|
|
49
67
|
format.html
|
50
|
-
format.json { render(json: QueuedJobsDatatable.new(view_context, @
|
68
|
+
format.json { render(json: QueuedJobsDatatable.new(view_context, @query)) }
|
51
69
|
end
|
52
70
|
end
|
53
71
|
|
54
72
|
def scheduled
|
55
|
-
@jobs
|
73
|
+
@jobs = RocketJob::Job.scheduled.only(SCHEDULED_FIELDS)
|
74
|
+
@query = RocketJobMissionControl::Query.new(@jobs, run_at: :asc)
|
75
|
+
@query.display_columns = %w[_type description runs_in cron_schedule]
|
56
76
|
respond_to do |format|
|
57
77
|
format.html
|
58
|
-
format.json { render(json: ScheduledJobsDatatable.new(view_context, @
|
78
|
+
format.json { render(json: ScheduledJobsDatatable.new(view_context, @query)) }
|
59
79
|
end
|
60
80
|
end
|
61
81
|
|
@@ -64,6 +84,7 @@ module RocketJobMissionControl
|
|
64
84
|
def show_sidebar
|
65
85
|
@jobs_sidebar = true
|
66
86
|
end
|
87
|
+
|
67
88
|
end
|
68
89
|
end
|
69
90
|
end
|
@@ -5,10 +5,10 @@ module RocketJobMissionControl
|
|
5
5
|
rescue_from StandardError, with: :error_occurred
|
6
6
|
|
7
7
|
def index
|
8
|
-
@
|
8
|
+
@query = RocketJobMissionControl::Query.new(RocketJob::Job.all, id: :desc)
|
9
9
|
respond_to do |format|
|
10
10
|
format.html
|
11
|
-
format.json { render(json: JobsDatatable.new(view_context, @
|
11
|
+
format.json { render(json: JobsDatatable.new(view_context, @query)) }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -28,13 +28,8 @@ module RocketJobMissionControl
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def destroy
|
31
|
-
|
32
|
-
|
33
|
-
redirect_to(jobs_path)
|
34
|
-
else
|
35
|
-
flash[:alert] = 'Cannot destroy a job unless it is completed or aborted'
|
36
|
-
redirect_to(job_path(@job))
|
37
|
-
end
|
31
|
+
@job.destroy
|
32
|
+
redirect_to(jobs_path)
|
38
33
|
end
|
39
34
|
|
40
35
|
def retry
|
@@ -56,7 +51,7 @@ module RocketJobMissionControl
|
|
56
51
|
end
|
57
52
|
|
58
53
|
def run_now
|
59
|
-
@job.
|
54
|
+
@job.unset(:run_at) if @job.scheduled?
|
60
55
|
redirect_to scheduled_jobs_path
|
61
56
|
end
|
62
57
|
|
@@ -72,6 +67,10 @@ module RocketJobMissionControl
|
|
72
67
|
def edit
|
73
68
|
end
|
74
69
|
|
70
|
+
def exceptions
|
71
|
+
@exceptions = @job.input.group_exceptions
|
72
|
+
end
|
73
|
+
|
75
74
|
private
|
76
75
|
|
77
76
|
def show_sidebar
|
@@ -79,9 +78,7 @@ module RocketJobMissionControl
|
|
79
78
|
end
|
80
79
|
|
81
80
|
def find_job_or_redirect
|
82
|
-
@job = RocketJob::Job.
|
83
|
-
|
84
|
-
if @job.nil?
|
81
|
+
unless @job = RocketJob::Job.where(id: params[:id]).first
|
85
82
|
flash[:alert] = t(:failure, scope: [:job, :find], id: params[:id])
|
86
83
|
|
87
84
|
redirect_to(jobs_path)
|
@@ -93,14 +90,14 @@ module RocketJobMissionControl
|
|
93
90
|
end
|
94
91
|
|
95
92
|
def job_params
|
96
|
-
params.require(:job).permit(RocketJob::Job.
|
93
|
+
params.require(:job).permit(RocketJob::Job.user_editable_fields)
|
97
94
|
end
|
98
95
|
|
99
96
|
def error_occurred(exception)
|
100
97
|
if defined?(SemanticLogger::Logger) && logger.is_a?(SemanticLogger::Logger)
|
101
98
|
logger.error 'Error loading a job', exception
|
102
99
|
else
|
103
|
-
logger.error "Error loading a job. #{
|
100
|
+
logger.error "Error loading a job. #{exception.class}: #{exception.message}\n#{(exception.backtrace || []).join("\n")}"
|
104
101
|
end
|
105
102
|
flash[:danger] = 'Error loading jobs.'
|
106
103
|
raise exception if Rails.env.development?
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module RocketJobMissionControl
|
2
|
+
module Servers
|
3
|
+
class IndexFiltersController < RocketJobMissionControl::ApplicationController
|
4
|
+
before_filter :show_sidebar
|
5
|
+
|
6
|
+
def starting
|
7
|
+
@servers = RocketJob::Server.starting
|
8
|
+
@query = RocketJobMissionControl::Query.new(@servers, name: :asc)
|
9
|
+
respond_to do |format|
|
10
|
+
format.html
|
11
|
+
format.json { render(json: ServersDatatable.new(view_context, @query)) }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def running
|
16
|
+
@servers = RocketJob::Server.running
|
17
|
+
@query = RocketJobMissionControl::Query.new(@servers, name: :asc)
|
18
|
+
respond_to do |format|
|
19
|
+
format.html
|
20
|
+
format.json { render(json: ServersDatatable.new(view_context, @query)) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def paused
|
25
|
+
@servers = RocketJob::Server.paused
|
26
|
+
@query = RocketJobMissionControl::Query.new(@servers, name: :asc)
|
27
|
+
respond_to do |format|
|
28
|
+
format.html
|
29
|
+
format.json { render(json: ServersDatatable.new(view_context, @query)) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def stopping
|
34
|
+
@servers = RocketJob::Server.stopping
|
35
|
+
@query = RocketJobMissionControl::Query.new(@servers, name: :asc)
|
36
|
+
respond_to do |format|
|
37
|
+
format.html
|
38
|
+
format.json { render(json: ServersDatatable.new(view_context, @query)) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def show_sidebar
|
45
|
+
@servers_sidebar = true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module RocketJobMissionControl
|
2
|
+
class ServersController < RocketJobMissionControl::ApplicationController
|
3
|
+
before_filter :find_server, only: [:stop, :pause, :resume, :destroy]
|
4
|
+
before_filter :show_sidebar
|
5
|
+
|
6
|
+
def index
|
7
|
+
@query = RocketJobMissionControl::Query.new(RocketJob::Server.all, name: :asc)
|
8
|
+
respond_to do |format|
|
9
|
+
format.html
|
10
|
+
format.json { render(json: ServersDatatable.new(view_context, @query)) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
VALID_STATES = {
|
15
|
+
stop_all: 'stopped',
|
16
|
+
pause_all: 'paused',
|
17
|
+
resume_all: 'resumed',
|
18
|
+
destroy_zombies: 'destroyed if zombified',
|
19
|
+
}
|
20
|
+
|
21
|
+
def update_all
|
22
|
+
server_action = params[:server_action].to_sym
|
23
|
+
if VALID_STATES.keys.include?(server_action)
|
24
|
+
RocketJob::Server.send(server_action.to_sym)
|
25
|
+
flash[:notice] = t(:success, scope: [:server, :update_all], server_action: VALID_STATES[server_action])
|
26
|
+
else
|
27
|
+
flash[:alert] = t(:invalid, scope: [:server, :update_all])
|
28
|
+
end
|
29
|
+
|
30
|
+
respond_to do |format|
|
31
|
+
format.html { redirect_to servers_path }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def stop
|
36
|
+
if @server.stop!
|
37
|
+
flash[:notice] = t(:success, scope: [:server, :stop])
|
38
|
+
else
|
39
|
+
flash[:alert] = t(:failure, scope: [:server, :stop])
|
40
|
+
end
|
41
|
+
|
42
|
+
respond_to do |format|
|
43
|
+
format.html { redirect_to servers_path }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def destroy
|
48
|
+
if @server.nil? || @server.destroy
|
49
|
+
flash[:notice] = t(:success, scope: [:server, :destroy])
|
50
|
+
else
|
51
|
+
flash[:alert] = t(:failure, scope: [:server, :destroy])
|
52
|
+
end
|
53
|
+
|
54
|
+
respond_to do |format|
|
55
|
+
format.html { redirect_to servers_path }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def pause
|
60
|
+
if @server.pause!
|
61
|
+
flash[:notice] = t(:success, scope: [:server, :pause])
|
62
|
+
else
|
63
|
+
flash[:alert] = t(:failure, scope: [:server, :pause])
|
64
|
+
end
|
65
|
+
|
66
|
+
respond_to do |format|
|
67
|
+
format.html { redirect_to servers_path }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def resume
|
72
|
+
if @server.resume!
|
73
|
+
flash[:notice] = t(:success, scope: [:server, :resume])
|
74
|
+
else
|
75
|
+
flash[:alert] = t(:failure, scope: [:server, :resume])
|
76
|
+
end
|
77
|
+
|
78
|
+
respond_to do |format|
|
79
|
+
format.html { redirect_to servers_path }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def find_server
|
86
|
+
@server = RocketJob::Server.find(params[:id])
|
87
|
+
end
|
88
|
+
|
89
|
+
def show_sidebar
|
90
|
+
@servers_sidebar = true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|