Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

promote sidekiq scroll; redis scroll gets $VCAP_SERVICE credentials

  • Loading branch information...
commit 35f22849493845a49b6d5001c9a6c05457137c38 1 parent 13aa992
@drnic authored
Showing with 29 additions and 1 deletion.
  1. +23 −1 scrolls/redis.rb
  2. +6 −0 scrolls/{untested → }/sidekiq.rb
View
24 scrolls/redis.rb
@@ -1,7 +1,29 @@
gem 'redis'
initializer "redis.rb", <<-RUBY
-REDIS = Redis.new
+if ENV['VCAP_SERVICES']
+ $vcap_services ||= JSON.parse(ENV['VCAP_SERVICES'])
+ redis_service_name = $vcap_services.keys.find { |svc| svc =~ /redis/i }
+ redis_service = $vcap_services[redis_service_name].first
+ $redis_config = {
+ host: redis_service['credentials']['host'],
+ port: redis_service['credentials']['port'],
+ password: redis_service['credentials']['password']
+ }
+else
+ $redis_config = {
+ host: '127.0.0.1',
+ port: 6379
+ }
+end
+
+$redis = Redis.new($redis_config)
+
+if $redis_config[:password]
+ $redis_url = "redis://:#{$redis_config[:password]}@#{$redis_config[:host]}:#{$redis_config[:port]}/0"
+else
+ $redis_url = "redis://#{$redis_config[:host]}:#{$redis_config[:port]}/0"
+end
RUBY
if scroll? "eycloud_recipes_on_deploy"
View
6 scrolls/untested/sidekiq.rb → scrolls/sidekiq.rb
@@ -1,5 +1,11 @@
gem "sidekiq"
+initializer "sidekiq.rb", <<-RUBY
+Sidekiq.configure_server do |config|
+ config.redis = { url: $redis_url }
+end
+RUBY
+
if scroll? "eycloud_recipes_on_deploy"
gem "eycloud-recipe-sidekiq", :group => :eycloud
Please sign in to comment.
Something went wrong with that request. Please try again.