What will you do when your apps are not working?
Read this blog! S&W team has summarized some useful tips for debugging apps in Cloud Foundry.
Logs
Logs are usually the best bet. Anything the application prints to standard output or standard error will show up in the cf logs
output for that application. If you don’t see any application logs, ensure that you are logging to stdout/stderr and no log files.
cf logs <APP> --recent
Events
Events will show you if/when the application containers crash, stop, restart, etc. They are useful for correlating with the log entries.
cf events <APP>
There are also several CF troubleshooting commands in Troubleshooting Application Deployment and Health.
SSH to the Diego Container
If the container SSH feature is enabled (which can be done on the command-line), you can actually SSH into the running Diego container and poke around. If you’re pushing Docker container images directly (rather than relying on buildpacks), you are free to add whatever diagnostics tools you want (strace, lsof, jconsole, etc.)
cf ssh <APP>
Monitoring
If you’ve got something like an MQTT sink that can absorb metrics and logging data, that can be useful (i.e. memory seems to increase at a constant rate until the container falls over). You can also hook app-level monitoring systems like DATADOG and New Relic in.
HTTP Tracing
HTTP Tracing is also an option, if you just need to be able to see what a CLI application communicating to a remote API is doing.
We wrote a tool called gotcha that presents a MiTM proxy that you can interpose between your test utility and the remote HTTP endpoint. The app is at starkandwayne/gotcha, and we’ve got a blog post about using Gotcha over at the blog: capture-http-requests-to-your-cloud-foundry.
Tips for Different Types of Applications
What sorts of applications (languages, frameworks, etc.) are you running? You may find different tools helpful.
Java and Ruby Applications
With Java or Ruby applications, if you use Eclipse, you might gain some value from How to Remotely Debug Cloud Foundry Apps,
, right from the comfort of your IDE!
Node Applications
You may find some helpful information on Debugging node apps running on Cloud Foundry.
中文版请见: [如何调适Cloud Foundry 中的应用?][如何调适Cloud Foundry 中的应用?].
[如何调适Cloud Foundry 中的应用?]:
https://www.starkandwayne.com//blog/ru-he-diao-gua-cloud-foundry-zhong-de-ying-yong/