Improved scheduler restart button handling in monitoring view.

This commit is contained in:
Jens Pfeifer 2017-09-07 14:33:09 +00:00
parent 7248be908f
commit 63aa9142af
4 changed files with 12 additions and 23 deletions

View file

@ -30,10 +30,7 @@ class Index extends App.ControllerSubContent
)
render: =>
@html App.view('monitoring')(
data: @data
job_restart_count: @job_restart_count
)
@html App.view('monitoring')(data: @data)
resetToken: (e) =>
e.preventDefault()
@ -53,8 +50,7 @@ class Index extends App.ControllerSubContent
type: 'POST'
url: "#{@apiPath}/monitoring/restart_failed_jobs"
success: (data) =>
@job_restart_count = data.job_restart_count
@render()
@load()
)
App.Config.set('Monitoring', { prio: 3600, name: 'Monitoring', parent: '#system', target: '#system/monitoring', controller: Index, permission: ['admin.monitoring'] }, 'NavBarAdmin')

View file

@ -34,14 +34,8 @@
<% end %>
<% end %>
</ul>
<% if !_.isEmpty(@data.issues): %>
<% if _.contains(@data.actions, 'restart_failed_jobs'): %>
<button class="btn btn--primary js-restartFailedJobs"><%- @T('Restart failed jobs') %></button>
<% if !_.isUndefined(@job_restart_count): %>
<p>
<%- @T('%s failed job(s) marked for restart', @job_restart_count) %>
<%- @T(', restarting...') if @job_restart_count > 0 %>
</p>
<% end %>
<% end %>
</div>

View file

@ -30,6 +30,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
token_or_permission_check
issues = []
actions = Set.new
# channel check
last_run_tolerance = Time.zone.now - 1.hour
@ -81,8 +82,9 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
issues.push 'scheduler not running'
end
Scheduler.where(status: 'error').each do |scheduler|
Scheduler.where(status: 'error', active: false).each do |scheduler|
issues.push "Failed to run scheduled job '#{scheduler.name}'. Cause: #{scheduler.error_message}"
actions.add(:restart_failed_jobs)
end
token = Setting.get('monitoring_token')
@ -100,8 +102,9 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
result = {
healthy: false,
message: issues.join(';'),
issues: issues,
token: token,
issues: issues,
actions: actions,
token: token,
}
render json: result
end
@ -180,15 +183,11 @@ curl http://localhost/api/v1/monitoring/status?token=XXX
def restart_failed_jobs
access_check
count = 0
Scheduler.where(status: 'error', active: false).each do |scheduler|
scheduler.update(active: true)
count += 1
end
render json: {
job_restart_count: count
}
render json: {}, status: :ok
end
private

View file

@ -1,4 +1,4 @@
class SchedulerStatus < ActiveRecord::Migration[4.2]
class SchedulerStatus < ActiveRecord::Migration
def up
# return if it's a new setup