2012-09-22 17:23:12 +02:00
|
|
|
# Custom Redis configuration
|
2012-11-20 17:57:45 +01:00
|
|
|
config_file = Rails.root.join('config', 'resque.yml')
|
2012-09-22 17:23:12 +02:00
|
|
|
|
|
|
|
if File.exists?(config_file)
|
|
|
|
resque_config = YAML.load_file(config_file)
|
2012-11-20 17:57:45 +01:00
|
|
|
Resque.redis = resque_config[Rails.env]
|
2012-09-22 17:23:12 +02:00
|
|
|
end
|
2012-11-20 17:59:00 +01:00
|
|
|
Resque.redis.namespace = 'resque:gitlab'
|
2012-09-22 17:23:12 +02:00
|
|
|
# Queues
|
2012-01-23 09:46:59 +01:00
|
|
|
Resque.watch_queue(PostReceive.instance_variable_get("@queue"))
|
2012-09-22 17:23:12 +02:00
|
|
|
|
|
|
|
# Authentication
|
|
|
|
require 'resque/server'
|
|
|
|
class Authentication
|
|
|
|
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 Authentication
|
|
|
|
|
|
|
|
# Mailer
|
|
|
|
Resque::Mailer.excluded_environments = []
|
2012-12-26 18:56:56 +01:00
|
|
|
|
|
|
|
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
|