Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improved logging in the worker scheduler.

  • Loading branch information...
commit 20df56202169e6037e4055029208347c2ea79eec 1 parent cdb506d
@bguthrie bguthrie authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 worker/email_scheduler.rb
View
14 worker/email_scheduler.rb
@@ -20,10 +20,20 @@ def self.schedule_email
amount_sent = PetitionEmailer.send(BATCH_SIZE).length
process.touch
- sleep_debt += WEEK/((max_emails_per_week/MailerProcessTracker.count)/amount_sent) - (Time.now-last_email)
- puts "Sleep debt: " + sleep_debt.to_s
+ if amount_sent.zero?
+ sleep_debt = 30
+ else
+ sleep_debt += WEEK/((max_emails_per_week/MailerProcessTracker.count)/amount_sent) - (Time.now-last_email)
+ end
+
+ Rails.logger.info "Sleep debt: #{sleep_debt}, sent: #{amount_sent}"
+
$statsd.gauge "email_sleep_debt", sleep_debt
+ if amount_sent == 0
+ sleep_debt = 30
+ end
+
if sleep_debt > 0
sleep(sleep_debt)
sleep_debt = 0
Please sign in to comment.
Something went wrong with that request. Please try again.