Use ExceptionNotification via generator generated code
Ensure that FoodsoftConfig is loaded before running the initalizers. This also enables notifaction for Resque.
This commit is contained in:
parent
386bc7382d
commit
9cd3c800bd
4 changed files with 59 additions and 28 deletions
5
Gemfile
5
Gemfile
|
@ -47,6 +47,7 @@ gem 'recurring_select'
|
||||||
gem 'roo'
|
gem 'roo'
|
||||||
gem 'roo-xls'
|
gem 'roo-xls'
|
||||||
gem 'spreadsheet'
|
gem 'spreadsheet'
|
||||||
|
gem 'exception_notification'
|
||||||
gem 'gaffe'
|
gem 'gaffe'
|
||||||
gem 'ruby-filemagic'
|
gem 'ruby-filemagic'
|
||||||
gem 'midi-smtp-server'
|
gem 'midi-smtp-server'
|
||||||
|
@ -63,10 +64,6 @@ gem 'foodsoft_discourse', path: 'plugins/discourse'
|
||||||
#gem 'foodsoft_documents', path: 'plugins/documents'
|
#gem 'foodsoft_documents', path: 'plugins/documents'
|
||||||
|
|
||||||
|
|
||||||
group :production do
|
|
||||||
gem 'exception_notification'
|
|
||||||
end
|
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'sqlite3'
|
gem 'sqlite3'
|
||||||
gem 'mailcatcher'
|
gem 'mailcatcher'
|
||||||
|
|
5
config/initializers/01_load_app_config.rb
Normal file
5
config/initializers/01_load_app_config.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Initial load the default config and database from rails environment
|
||||||
|
# See config/app_config.yml for further details
|
||||||
|
# Load Config, start by selecting defaults via current environment
|
||||||
|
require 'foodsoft_config'
|
||||||
|
FoodsoftConfig.init
|
53
config/initializers/exception_notification.rb
Normal file
53
config/initializers/exception_notification.rb
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
require 'exception_notification/rails'
|
||||||
|
|
||||||
|
|
||||||
|
require 'resque/failure/multiple'
|
||||||
|
require 'resque/failure/redis'
|
||||||
|
require 'exception_notification/resque'
|
||||||
|
|
||||||
|
Resque::Failure::Multiple.classes = [Resque::Failure::Redis, ExceptionNotification::Resque]
|
||||||
|
Resque::Failure.backend = Resque::Failure::Multiple
|
||||||
|
|
||||||
|
|
||||||
|
ExceptionNotification.configure do |config|
|
||||||
|
# Ignore additional exception types.
|
||||||
|
# ActiveRecord::RecordNotFound, Mongoid::Errors::DocumentNotFound, AbstractController::ActionNotFound and ActionController::RoutingError are already added.
|
||||||
|
# config.ignored_exceptions += %w{ActionView::TemplateError CustomError}
|
||||||
|
|
||||||
|
# Adds a condition to decide when an exception must be ignored or not.
|
||||||
|
# The ignore_if method can be invoked multiple times to add extra conditions.
|
||||||
|
config.ignore_if do |exception, options|
|
||||||
|
Rails.env.development? || Rails.env.test?
|
||||||
|
end
|
||||||
|
|
||||||
|
# Notifiers =================================================================
|
||||||
|
|
||||||
|
# Email notifier sends notifications by email.
|
||||||
|
if notification = FoodsoftConfig[:notification]
|
||||||
|
config.add_notifier :email, {
|
||||||
|
:email_prefix => notification[:email_prefix],
|
||||||
|
:sender_address => notification[:sender_address],
|
||||||
|
:exception_recipients => notification[:error_recipients],
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
# Campfire notifier sends notifications to your Campfire room. Requires 'tinder' gem.
|
||||||
|
# config.add_notifier :campfire, {
|
||||||
|
# :subdomain => 'my_subdomain',
|
||||||
|
# :token => 'my_token',
|
||||||
|
# :room_name => 'my_room'
|
||||||
|
# }
|
||||||
|
|
||||||
|
# HipChat notifier sends notifications to your HipChat room. Requires 'hipchat' gem.
|
||||||
|
# config.add_notifier :hipchat, {
|
||||||
|
# :api_token => 'my_token',
|
||||||
|
# :room_name => 'my_room'
|
||||||
|
# }
|
||||||
|
|
||||||
|
# Webhook notifier sends notifications over HTTP protocol. Requires 'httparty' gem.
|
||||||
|
# config.add_notifier :webhook, {
|
||||||
|
# :url => 'http://example.com:5555/hubot/path',
|
||||||
|
# :http_method => :post
|
||||||
|
# }
|
||||||
|
|
||||||
|
end
|
|
@ -1,24 +0,0 @@
|
||||||
# Initial load the default config and database from rails environment
|
|
||||||
# See config/app_config.yml for further details
|
|
||||||
# Load Config, start by selecting defaults via current environment
|
|
||||||
require 'foodsoft_config'
|
|
||||||
FoodsoftConfig.init
|
|
||||||
|
|
||||||
Foodsoft::Application.configure do
|
|
||||||
# Set action mailer default host for url generating
|
|
||||||
[:protocol, :host, :port].each do |k|
|
|
||||||
config.action_mailer.default_url_options[k] = FoodsoftConfig[k] if FoodsoftConfig[k]
|
|
||||||
end
|
|
||||||
|
|
||||||
if %w(production).include? Rails.env
|
|
||||||
# Configuration of the exception_notification plugin
|
|
||||||
# Mailadresses are set in config/app_config.yml
|
|
||||||
config.middleware.use ExceptionNotification::Rack,
|
|
||||||
:email => {
|
|
||||||
:email_prefix => FoodsoftConfig[:notification]['email_prefix'],
|
|
||||||
:sender_address => FoodsoftConfig[:notification]['sender_address'],
|
|
||||||
:exception_recipients => FoodsoftConfig[:notification]['error_recipients']
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in a new issue