2012-09-22 11:23:12 -04:00
|
|
|
# Custom Redis configuration
|
2012-11-20 11:57:45 -05:00
|
|
|
config_file = Rails.root.join('config', 'resque.yml')
|
2012-09-22 11:23:12 -04:00
|
|
|
|
|
|
|
if File.exists?(config_file)
|
|
|
|
resque_config = YAML.load_file(config_file)
|
2012-11-20 11:57:45 -05:00
|
|
|
Resque.redis = resque_config[Rails.env]
|
2012-09-22 11:23:12 -04:00
|
|
|
end
|
2012-11-20 11:59:00 -05:00
|
|
|
Resque.redis.namespace = 'resque:gitlab'
|
2012-12-25 09:18:22 -05:00
|
|
|
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
|
2012-09-22 11:23:12 -04:00
|
|
|
|
|
|
|
# Authentication
|
|
|
|
require 'resque/server'
|
2012-12-25 09:18:22 -05:00
|
|
|
class ResqueAuthentication
|
2012-09-22 11:23:12 -04:00
|
|
|
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
|
|
|
|
|
2012-12-25 09:18:22 -05:00
|
|
|
Resque::Server.use ResqueAuthentication
|
2012-09-22 11:23:12 -04:00
|
|
|
|
|
|
|
# Mailer
|
|
|
|
Resque::Mailer.excluded_environments = []
|
2012-12-25 08:53:50 -05:00
|
|
|
|