Skip to content

Output errors summary #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/services/check_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ def sync_dates # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
end

group_finished_at = Time.now
check_ids = checks.map(&:id)
check_logs = check_errors_scope(check_ids: check_ids,
after_date: group_started_at,
before_date: group_finished_at).includes(:check).all

check_errors_scope(check_ids: checks.map(&:id),
after_date: group_started_at,
before_date: group_finished_at).includes(:check).each do |check_log|
message = "#{self.class.name}: #{check_logs.count} error(s) found for checks '#{check_ids.join(',')}' between '#{group_started_at}' and '#{group_finished_at}'" # rubocop:disable Metrics/LineLength
logger.debug(message)

check_logs.each do |check_log|
message = "#{self.class.name}: check ##{check_log.check_id} for '#{check_log.check.domain}' failed (#{check_log.exit_status}) ; #{check_log.error.lines.first}" # rubocop:disable Metrics/LineLength
logger.error(message)
end
Expand Down
5 changes: 3 additions & 2 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

set :output, standard: "log/cron.log"

#
job_type :rake_with_stdout, "cd :path && :environment_variable=:environment bundle exec rake :task"

# every 2.hours do
# command "/usr/bin/some_great_command"
# runner "MyModel.some_method"
Expand All @@ -19,7 +20,7 @@
# Learn more: http://github.com/javan/whenever

every 1.day, at: '1:00 am', roles: [:app] do
rake "checks:sync_dates:all"
rake_with_stdout "checks:sync_dates:all VERBOSE=1"
end

every 1.day, at: '8:30 am', roles: [:app] do
Expand Down