Last active
August 29, 2015 14:00
-
-
Save tareksamni/03325d7ac950c8872897 to your computer and use it in GitHub Desktop.
Sidekiq Initializer base on current active environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## For more details refer to: http://tsamni.com/post/84515089035/sidekiq-performing-background-or-delayed-jobs-with | |
# config/redis.yml | |
# Redis db configuration file | |
# development environment | |
development: | |
host: 'localhost' | |
port: '6379' | |
# local testing environment | |
test: | |
host: 'localhost' | |
port: '6379' | |
# production environment | |
production: | |
host: 'your.aws.elastic.cache.instance.endpoint.cache.amazonaws.com' | |
port: '6379' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## For more details refer to: http://tsamni.com/post/84515089035/sidekiq-performing-background-or-delayed-jobs-with | |
# config/initializers/sidekiq.rb | |
rails_root = Rails.root || File.dirname(__FILE__) + '/../..' | |
rails_env = Rails.env || 'development' | |
redis_config = YAML.load_file(rails_root.to_s + '/config/redis.yml') | |
redis_config.merge! redis_config.fetch(Rails.env, {}) | |
redis_config.symbolize_keys! | |
Sidekiq.configure_server do |config| | |
config.redis = { :url => "redis://#{redis_config[:host]}:#{redis_config[:port]}/12", :namespace => 'Sidekiq' } | |
end | |
Sidekiq.configure_client do |config| | |
config.redis = { :url => "redis://#{redis_config[:host]}:#{redis_config[:port]}/12", :namespace => 'Sidekiq' } | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment