forked from martindale/toshi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.rb
41 lines (34 loc) · 1 KB
/
environment.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require_relative 'application'
require 'bugsnag'
Bugsnag.configure do |config|
config.api_key = ENV['BUGSNAG_API_KEY']
config.endpoint = ENV['BUGSNAG_URL']
config.notify_release_stages = ['production']
config.project_root = Toshi.root.to_s
config.release_stage = Toshi.env.to_s
config.use_ssl = true
end
# sync stdout to make logging easier
STDOUT.sync = true unless Toshi.env == :production
# connect db
Toshi.connect_database
def error_handler ex, ctx_hash
p ex
ex.backtrace.each{|frame|
p frame
}
end
# connect sidekiq/redis
Sidekiq.configure_server{|config|
config.redis = { url: Toshi.settings[:redis_url] }
config.error_handlers << Proc.new {|ex,ctx_hash| error_handler(ex, ctx_hash) }
}
Sidekiq.configure_client{|config|
config.redis = { url: Toshi.settings[:redis_url] }
config.error_handlers << Proc.new {|ex,ctx_hash| error_handler(ex, ctx_hash) }
}
# run sidekiq synchronously in test environment
if Toshi.env == :test
require 'sidekiq/testing'
Sidekiq::Testing.inline!
end