Resque.redis = Rails.application.config.redis_host

require 'resque_failed_job_mailer'

Resque::Failure::Notifier.configure do |config|
  config.to = Rails.application.config.email_alerts_alias
  config.from = Rails.application.config.email_generic_from
end

#Resque::Failure::Multiple.classes = [ResqueJamError]
Resque::Failure::Multiple.classes = [Resque::Failure::Notifier, ResqueJamError]
Resque::Failure.backend = Resque::Failure::Multiple

if File.split($0).last != 'rake' && Rails.env == 'development' && (ENV['RUN_JOBS_INLINE'] == '1' || ENV['RUN_INLINE_JOBS'] == '1')

  Thread.new do
    system('INTERVAL=1 bundle exec rake all_jobs')
  end

  Thread.new do
    system('bundle exec rake scheduler')
  end
end