my app needs to get the number of instances in which its running, (in runtime my app uses this info in my program logic)


Zuba Al <myfakename90@...>
 

evaluating the performance of my app.
how my app can get the number of instances in which its running. in runtime it needs this info in my logic.


CF Runtime
 

This information is not provided to the app. You can see what data is
provided here:
http://docs.run.pivotal.io/devguide/deploy-apps/environment-variable.html#instance-vars

If you want to get this information for you app, the best way would be to
have the app call the API directly and see what the "instances" attribute
is set to.
http://apidocs.cloudfoundry.org/218/apps/retrieve_a_particular_app.html

Joseph
CF Release Integration Team

On Mon, Sep 28, 2015 at 12:14 PM, zooba Sir <myfakename90(a)gmail.com> wrote:

evaluating the performance of my app.
how my app can get the number of instances in which its running. in
runtime it needs this info in my logic.


Zuba Al <myfakename90@...>
 

will this "instance" attribute gives number of successfully running instances at the moment or just the maximum no of instances for the app as configured in manifest.yml


Zuba Al <myfakename90@...>
 

Also, please let me know how to call the API in my code.

Thanks.


Alexander Lomov <alexander.lomov@...>
 

Hey, Sir Zooba. Sorry for the late response.

You can find the description of Cloud Controller API here [1]. You can make requests to your Cloud Controller through Gorouter component adding “api.” before main CF domain. For instance if you have CF deployment to cf-example.com<http://cf-example.com> domain, then you’ll need to use http://api.cf-example.com to reach CC.

The better option will be to use API wrappers for the language you work with. For instance for ruby you can choose this one [2].

[1] http://apidocs.cloudfoundry.org/218/
[2] https://github.com/frodenas/cloudfoundry-client

On Sep 30, 2015, at 7:32 PM, zooba Sir <myfakename90(a)gmail.com<mailto:myfakename90(a)gmail.com>> wrote:

Also, please let me know how to call the API in my code.

Thanks.


Alexander Lomov <alexander.lomov@...>
 

Actually I made a mistake here. The gem you may to use as a API wrapper for Ruby is called cfoundry [1]. While it may not have support for the latest versions of CF, I was able to use it in may projects. For instance this simple app [2].

[1] https://github.com/cloudfoundry-attic/cfoundry
[2] https://github.com/allomov/cf-auto-scaling/blob/master/Gemfile#L6

On Sep 30, 2015, at 8:11 PM, Lomov Alexander <alexander.lomov(a)altoros.com<mailto:alexander.lomov(a)altoros.com>> wrote:

Hey, Sir Zooba. Sorry for the late response.

You can find the description of Cloud Controller API here [1]. You can make requests to your Cloud Controller through Gorouter component adding “api.” before main CF domain. For instance if you have CF deployment to cf-example.com<http://cf-example.com/> domain, then you’ll need to use http://api.cf-example.com<http://api.cf-example.com/> to reach CC.

The better option will be to use API wrappers for the language you work with. For instance for ruby you can choose this one [2].

[1] http://apidocs.cloudfoundry.org/218/
[2] https://github.com/frodenas/cloudfoundry-client

On Sep 30, 2015, at 7:32 PM, zooba Sir <myfakename90(a)gmail.com<mailto:myfakename90(a)gmail.com>> wrote:

Also, please let me know how to call the API in my code.

Thanks.


CF Runtime
 

The "instances" attribute from the api will give the current number of
instances that should be running. If a user has recently changed this via
the API, the actual number of running instances may be different.

Using the cf cli by shelling out from your app is always a good way to
access the api.

Joseph
CF Release Integration Team

On Wed, Sep 30, 2015 at 7:16 AM, zooba Sir <myfakename90(a)gmail.com> wrote:

will this "instance" attribute gives number of successfully running
instances at the moment or just the maximum no of instances for the app as
configured in manifest.yml