Debugging PaaS App Instances¶
Logging in¶
Log in to your PaaS account using the CF cli:
cf login -a https://api.cloud.service.gov.uk --sso
Get into the correct space:
cf target -s <monitoring|sandbox|preview|staging|production>
Showing the environment¶
List the apps:
cf apps
List the instances of a given app:
cf app <app_name>
List the environment variables for an app:
cf env <app_name>
Some of these are injected by PaaS (System-Provided), others are injected by us (User-Provided).
For example, to find endpoints for bound backing services, look under
System-Provided variables for VCAP_SERVICES[<service>][0]['credentials']
and check the entries for ['uri']
(or ['uris']
for HA services).
Warning
Be aware of shoulder surfers as this will display all the app’s secret credentials on screen.
Using SSH¶
Make sure that ssh is enabled on the app you want to access e.g.:
cf enable-ssh <app_name>
Important
You should disable ssh after your debugging session using cf enable-ssh <app_name>
SSH in (optionally specifying an instance number):
cf ssh <app_name> 0
Useful commands¶
On the command line using curl you can check you can hit another service eg.:
$ curl https://dm-search-api-preview.cloudapps.digital
{
"error": "Unauthorized, bearer token must be provided"
}
On the command line using cat you can view the logs:
$ cat /app/supervisord.log
$ cat /var/log/awslogs.log
$ cat /var/log/digitalmarketplace/nginx_access.log
$ cat /var/log/digitalmarketplace/application.log
Disabling health checks¶
An instance whose health checks are failing will be killed by PaaS within a minute or so, which makes such an instance difficult to debug. These health checks can temporarily be disabled by issuing:
cf push <app_name> -u none
Note however that this itself will cause all instances to restart to apply the change.
After you’re finished you can restore the healthcheck to its previous value using the -u
flag, though it should also
return to it’s normal value the next time this app is released.
Restarting apps or rebuilding app artifacts (causes downtime)¶
In rare situations like binding a new service it may be necessary to restart an app or app instance using restart or restart-app-instance.
In very rare situations; for instance changing how our stack is arranged or completely changing how the app is built on PaaS you may want read up on restaging, starting and stopping apps.