Improved scheduler restart button handling in monitoring view.
This commit is contained in:
parent
7248be908f
commit
63aa9142af
4 changed files with 12 additions and 23 deletions
|
@ -30,10 +30,7 @@ class Index extends App.ControllerSubContent
|
||||||
)
|
)
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
@html App.view('monitoring')(
|
@html App.view('monitoring')(data: @data)
|
||||||
data: @data
|
|
||||||
job_restart_count: @job_restart_count
|
|
||||||
)
|
|
||||||
|
|
||||||
resetToken: (e) =>
|
resetToken: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
@ -53,8 +50,7 @@ class Index extends App.ControllerSubContent
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
url: "#{@apiPath}/monitoring/restart_failed_jobs"
|
url: "#{@apiPath}/monitoring/restart_failed_jobs"
|
||||||
success: (data) =>
|
success: (data) =>
|
||||||
@job_restart_count = data.job_restart_count
|
@load()
|
||||||
@render()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
App.Config.set('Monitoring', { prio: 3600, name: 'Monitoring', parent: '#system', target: '#system/monitoring', controller: Index, permission: ['admin.monitoring'] }, 'NavBarAdmin')
|
App.Config.set('Monitoring', { prio: 3600, name: 'Monitoring', parent: '#system', target: '#system/monitoring', controller: Index, permission: ['admin.monitoring'] }, 'NavBarAdmin')
|
||||||
|
|
|
@ -34,14 +34,8 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<% if !_.isEmpty(@data.issues): %>
|
<% if _.contains(@data.actions, 'restart_failed_jobs'): %>
|
||||||
<button class="btn btn--primary js-restartFailedJobs"><%- @T('Restart failed jobs') %></button>
|
<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 %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
|
||||||
token_or_permission_check
|
token_or_permission_check
|
||||||
|
|
||||||
issues = []
|
issues = []
|
||||||
|
actions = Set.new
|
||||||
|
|
||||||
# channel check
|
# channel check
|
||||||
last_run_tolerance = Time.zone.now - 1.hour
|
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'
|
issues.push 'scheduler not running'
|
||||||
end
|
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}"
|
issues.push "Failed to run scheduled job '#{scheduler.name}'. Cause: #{scheduler.error_message}"
|
||||||
|
actions.add(:restart_failed_jobs)
|
||||||
end
|
end
|
||||||
|
|
||||||
token = Setting.get('monitoring_token')
|
token = Setting.get('monitoring_token')
|
||||||
|
@ -101,6 +103,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
|
||||||
healthy: false,
|
healthy: false,
|
||||||
message: issues.join(';'),
|
message: issues.join(';'),
|
||||||
issues: issues,
|
issues: issues,
|
||||||
|
actions: actions,
|
||||||
token: token,
|
token: token,
|
||||||
}
|
}
|
||||||
render json: result
|
render json: result
|
||||||
|
@ -180,15 +183,11 @@ curl http://localhost/api/v1/monitoring/status?token=XXX
|
||||||
def restart_failed_jobs
|
def restart_failed_jobs
|
||||||
access_check
|
access_check
|
||||||
|
|
||||||
count = 0
|
|
||||||
Scheduler.where(status: 'error', active: false).each do |scheduler|
|
Scheduler.where(status: 'error', active: false).each do |scheduler|
|
||||||
scheduler.update(active: true)
|
scheduler.update(active: true)
|
||||||
count += 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: {
|
render json: {}, status: :ok
|
||||||
job_restart_count: count
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class SchedulerStatus < ActiveRecord::Migration[4.2]
|
class SchedulerStatus < ActiveRecord::Migration
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
|
|
Loading…
Reference in a new issue