summaryrefslogtreecommitdiff
path: root/config/initializers/4_resque.rb
blob: ab34050cb500d72dfde66397b56dacbc68e2ff59 (plain)
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
# 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 = []