Skip to content

Commit

Permalink
connect to redis if has credentials in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
bibendi committed Oct 23, 2014
1 parent 85e4ef7 commit ad37905
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ end
Создайте файл `config/resque.yml` с несколькими секциями:
```yaml
# конфигурация redis
# секция не обязательная, вы сами можете настроить подключение через Resque.redis = Redis.new
redis:
host: bz-redis
port: 6379
Expand Down
2 changes: 1 addition & 1 deletion lib/resque/integration/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def initialize(*paths)
#
# @return [OpenStruct]
def redis
@redis ||= (self['redis'] || {}).symbolize_keys.merge(:thread_safe => true)
@redis ||= (self['redis'] || {}).symbolize_keys
end

# Returns workers configuration
Expand Down
6 changes: 4 additions & 2 deletions lib/resque/integration/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ class Engine < Rails::Engine
initializer 'resque-integration.redis' do
redis = Resque.config.redis

Resque.redis = Redis.new(redis)
Resque.redis.namespace = redis[:namespace] if redis[:namespace]
if redis.any?
Resque.redis = Redis.new(redis)
Resque.redis.namespace = redis[:namespace] if redis[:namespace]
end
end

# Конфигурирование плагина resque-failed-job-mailer.
Expand Down

0 comments on commit ad37905

Please sign in to comment.