Created
September 25, 2013 09:12
-
-
Save thoward/6697048 to your computer and use it in GitHub Desktop.
Cloud Foundry Service Shims for Rabbit/Redis configs
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
#!/usr/bin/env ruby | |
# | |
# Shims Rabbit configuration for CloudFoundry | |
# | |
require 'json' | |
if ENV['VCAP_SERVICES'] | |
$vcap_services ||= JSON.parse(ENV['VCAP_SERVICES']) | |
rabbit_service_name = $vcap_services.keys.find { |svc| svc =~ /rabbit/i } | |
rabbit_service = $vcap_services[rabbit_service_name].first | |
$rabbit_url = rabbit_service['credentials']['url'] | |
else | |
$rabbit_url = "amqp://localhost" | |
end | |
ENV['RABBITMQ_URL']=$rabbit_url |
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
#!/usr/bin/env ruby | |
# | |
# Shims Redis configuration for CloudFoundry | |
# | |
require 'json' | |
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 | |
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 | |
ENV['REDIS_URL']=redis_url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment