diff --git a/app/assets/javascripts/app/controllers/monitoring.coffee b/app/assets/javascripts/app/controllers/monitoring.coffee index b483057bd..2b6900248 100644 --- a/app/assets/javascripts/app/controllers/monitoring.coffee +++ b/app/assets/javascripts/app/controllers/monitoring.coffee @@ -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') diff --git a/app/assets/javascripts/app/views/monitoring.jst.eco b/app/assets/javascripts/app/views/monitoring.jst.eco index d5650ee79..ceea50003 100644 --- a/app/assets/javascripts/app/views/monitoring.jst.eco +++ b/app/assets/javascripts/app/views/monitoring.jst.eco @@ -34,15 +34,9 @@ <% end %> <% end %> - <% if !_.isEmpty(@data.issues): %> + <% if _.contains(@data.actions, 'restart_failed_jobs'): %> - <% if !_.isUndefined(@job_restart_count): %> -

- <%- @T('%s failed job(s) marked for restart', @job_restart_count) %> - <%- @T(', restarting...') if @job_restart_count > 0 %> -

- <% end %> <% end %> - \ No newline at end of file + diff --git a/app/controllers/monitoring_controller.rb b/app/controllers/monitoring_controller.rb index 4da0addde..82980318c 100644 --- a/app/controllers/monitoring_controller.rb +++ b/app/controllers/monitoring_controller.rb @@ -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 diff --git a/db/migrate/20170515000001_scheduler_status.rb b/db/migrate/20170515000001_scheduler_status.rb index dcaa8ef87..6c55b2ff7 100644 --- a/db/migrate/20170515000001_scheduler_status.rb +++ b/db/migrate/20170515000001_scheduler_status.rb @@ -1,4 +1,4 @@ -class SchedulerStatus < ActiveRecord::Migration[4.2] +class SchedulerStatus < ActiveRecord::Migration def up # return if it's a new setup