Skip to content

Instantly share code, notes, and snippets.

@patio11
Created October 29, 2014 06:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patio11/00a55604942b12c9584c to your computer and use it in GitHub Desktop.
Save patio11/00a55604942b12c9584c to your computer and use it in GitHub Desktop.
A snippet from my Rakefile which uses Twilio.
#This Rake task fires every 5 minutes, checking for a particular symptom which signals a critical problem.
#If it finds it, it calls Patrick's cell phone.
#This could probably be done with PagerDuty or similar, but since I already had a Twilio account...
desc "Emails sysadmin if reminders are not going out"
task :check_for_emergency => :environment do
begin
had_emergency = Reminder.check_for_emergency! #Application code checks for a symptom of a critical problem.
if (had_emergency)
twimlet_url = "http://twimlets.com/message?Message%5B0%5D=Appointment%20reminder%20reminders%20in%20processing%20or%20scheduled.%20Appointment%20reminder%20reminders%20in%20processing%20or%20scheduled.%20Appointment%20reminder%20reminders%20in%20processing%20or%20scheduled."
Twilio::Call.make($TOLL_FREE_NUMBER, $TWILIO_WHITELISTED_JAPAN_CELL_PHONE, twimlet_url)
end
rescue Exception => e
HoptoadNotifier.notify(e)
raise # to show error in console
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment