From 10dcc7f05ae7badab8110c7b033570f797994ab8 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Mon, 15 Aug 2011 14:15:10 +0800 Subject: [PATCH] Added error handling for Errbit itself. Errors are sent to a centralized instance by default, but this can be changed in config.yml [ci skip] --- config/config.example.yml | 10 ++++++++++ config/initializers/_load_config.rb | 6 ++++++ config/initializers/hoptoad.rb | 9 +++++++++ 3 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 config/initializers/hoptoad.rb diff --git a/config/config.example.yml b/config/config.example.yml index 1ab5dc3..d1fa754 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -31,3 +31,13 @@ confirm_resolve_err: true # Helpful if you want to plug in your own authentication strategy. user_has_username: false +# Configure tracking for Errbit's own internal errors. +# There is a central Errbit instance running on heroku, +# and other Errbit instances will send their errors there by default. +# Please leave this section commented unless you really need to change it. +# ------------------------------------------------------------------------ +# report_self_errors: true +# self_errors_host: errbit-central.heroku.com +# self_errors_port: 80 +# self_errors_api_key: 11e5ce322856e540481e6a0789893179 + diff --git a/config/initializers/_load_config.rb b/config/initializers/_load_config.rb index 561ee38..bf0ff13 100644 --- a/config/initializers/_load_config.rb +++ b/config/initializers/_load_config.rb @@ -6,6 +6,12 @@ if ENV['HEROKU'] Errbit::Config.host = ENV['ERRBIT_HOST'] Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM'] Errbit::Config.email_at_notices = [1,3,10] #ENV['ERRBIT_EMAIL_AT_NOTICES'] + + Errbit::Config.report_self_errors = ENV['ERRBIT_REPORT_SELF_ERRORS'] + Errbit::Config.self_errors_host = ENV['ERRBIT_SELF_ERRORS_HOST'] + Errbit::Config.self_errors_port = ENV['ERRBIT_SELF_ERRORS_PORT'] + Errbit::Config.self_errors_api_key = ENV['ERRBIT_SELF_ERRORS_API_KEY'] + Errbit::Application.config.action_mailer.smtp_settings = { :address => "smtp.sendgrid.net", :port => "25", diff --git a/config/initializers/hoptoad.rb b/config/initializers/hoptoad.rb new file mode 100644 index 0000000..40b1c0f --- /dev/null +++ b/config/initializers/hoptoad.rb @@ -0,0 +1,9 @@ +if Rails.env.production? && Errbit::Config.report_self_errors.to_s != "false" + HoptoadNotifier.configure do |config| + config.api_key = Errbit::Config.api_key || "11e5ce322856e540481e6a0789893179" + config.host = Errbit::Config.host || "errbit-central.heroku.com" + config.port = Errbit::Config.port || 80 + config.secure = config.port == 443 + end +end + -- libgit2 0.21.2