Merge pull request #46 from Evolix/cron-fixes

Cron fixes
This commit is contained in:
Colin Darie 2018-07-06 13:13:44 +02:00 committed by GitHub
commit aa97430e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View File

@ -22,7 +22,7 @@ class CheckLogger
check_log.exit_status = result.exit_status
check_log.raw_response = result.stdout
if result.exit_status > 0 # rubocop:disable Style/NumericPredicate
if result.exit_status.nil? || result.exit_status > 0 # rubocop:disable Style/NumericPredicate
check_log.error = result.stderr
check_log.status = :failed
end

View File

@ -18,10 +18,10 @@ set :output, standard: "log/cron.log"
# Learn more: http://github.com/javan/whenever
every 1.day, at: '4:30 am', roles: [:app] do
every 1.day, at: '1:00 am', roles: [:app] do
rake "checks:sync_dates:all"
end
every 1.day, at: '10:30 am', roles: [:app] do
every 1.day, at: '8:30 am', roles: [:app] do
rake "notifications:send_all"
end

View File

@ -9,7 +9,7 @@ namespace :checks do
end
desc "Refresh SSL expiry dates"
task domain: :environment do
task ssl: :environment do
process = CheckSSLProcessor.new
process.sync_dates
end

View File

@ -39,6 +39,16 @@ class CheckLoggerTest < ActiveSupport::TestCase
assert @logger.check_log.failed?
end
test "should log an error when there is not exit status" do
result = SystemCommandResult.new("command", nil, nil, "an error")
@logger.log :after_command, result
assert_nil @logger.check_log.raw_response
assert_equal "an error", @logger.check_log.error
assert_nil @logger.check_log.exit_status
assert @logger.check_log.failed?
end
test "should log a successful parsed response" do
response = OpenStruct.new(
domain: "example.fr",