gitlabhq/config/initializers/4_resque.rb
Dmitriy Zaporozhets 3c1022f9b1 No resque errors
2012-12-25 16:18:22 +02:00

30 lines
715 B
Ruby

# Custom Redis configuration
config_file = Rails.root.join('config', 'resque.yml')
if File.exists?(config_file)
resque_config = YAML.load_file(config_file)
Resque.redis = resque_config[Rails.env]
end
Resque.redis.namespace = 'resque:gitlab'
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
# Authentication
require 'resque/server'
class ResqueAuthentication
def initialize(app)
@app = app
end
def call(env)
account = env['warden'].authenticate!(:database_authenticatable, :rememberable, scope: :user)
raise "Access denied" if !account.admin?
@app.call(env)
end
end
Resque::Server.use ResqueAuthentication
# Mailer
Resque::Mailer.excluded_environments = []