Skip to main content

Managing and Binding Services

Comments

2 comments

  • jakob

    Just created a Redis service - where can I find it's: host, password, db and port in order to use it?

    0
  • owolf

    Hi Jakob,

    if you create a service you should map them to an application. This is done by executing:

    cf bind-service <service-instance-name> --app <appname>

     

    After that the information you are looking for are available as environment variables. This environment variables are accessible through your application.  For example, in an application written in Ruby you can read these credentials like this:

    require 'json'
    JSON.parse( ENV['VCAP_SERVICES'] )['redis-2.2'].first['credentials']['hostname']
    JSON.parse( ENV['VCAP_SERVICES'] )['redis-2.2'].first['credentials']['port']
    JSON.parse( ENV['VCAP_SERVICES'] )['redis-2.2'].first['credentials']['password'] 
    JSON.parse( ENV['VCAP_SERVICES'] )['redis-2.2'].first['credentials']['name']

     

    I hope this helps, just let us know if you need some more help.

    Best Regards

    0

Please sign in to leave a comment.

Powered by Zendesk