sidekiq
This commit is contained in:
parent
7bfd38eaa9
commit
c7bb3a1f72
14 changed files with 75 additions and 94 deletions
|
@ -1,29 +1,22 @@
|
|||
# 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 }
|
||||
resque_url = if File.exists?(config_file)
|
||||
YAML.load_file(config_file)[Rails.env]
|
||||
else
|
||||
"localhost:6379"
|
||||
end
|
||||
|
||||
# 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
|
||||
Sidekiq.configure_server do |config|
|
||||
config.redis = {
|
||||
url: "redis://#{resque_url}",
|
||||
namespace: 'resque:gitlab'
|
||||
}
|
||||
end
|
||||
|
||||
Resque::Server.use ResqueAuthentication
|
||||
|
||||
# Mailer
|
||||
Resque::Mailer.excluded_environments = []
|
||||
|
||||
Sidekiq.configure_client do |config|
|
||||
config.redis = {
|
||||
url: "redis://#{resque_url}",
|
||||
namespace: 'resque:gitlab'
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue