Community

Collecting Diagnostic Data After a Crash

Share this post:

If a Liberty Bluemix application crashes, the default behavior is that it will immediately restart. The problem with this behavior is that all diagnostic files such as dumps and traces are lost. In order to delay the restart so that dumps and traces can be collected, set this environment variable for your application:

IBM_JAVA_OPTIONS: -Xdump:tool:events=gpf,exec="sleep 1d" -Xdump:what

This environment variable results in the JVM remaining available (but non-functional) after a crash. Traces and dumps can be collected with the cf files command, and then the application can be restarted with cf stop and cf start.

The application will be automatically restarted after the time period specified on the sleep command (1 day, in the above example). Note that you can specify any time period using s, m, h, or d for seconds, minutes, hours, or days, respectively.

Setting the environment variable can be done in a number of ways:

  • Using the cf push command with -f option to provide a manifest.yml that contains the environment variable. Here is a sample manifest.yml:
<strong><code># manifest for crashTest<br />applications:<br />- name: crashTest<br />  memory: 512M<br />  path: c:\tmp\zips\crashTest.zip<br />  env:<br />    IBM_JAVA_OPTIONS: -Xdump:tool:events=gpf,exec="sleep 1d" -Xdump:what</code></strong>
  • Using the cf set-env command on an already pushed app, followed by cf push to activate the new setting. This command requires outer quotes for the entire value and escaping the inner quotes around the sleep command with backslashes like this:

cf set-env <appName> IBM_JAVA_OPTIONS "-Xdump:tool:events=gpf,exec=\"sleep 1d\" -Xdump:what"

  • Using the ACU UI to set the environment variable under the runtime. The application is automatically restarted when you press ‘save’. No outer quotes or backslashes are required on the value.

Details on the -Xdump option can be found here:
http://www-01.ibm.com/support/docview.wss?uid=swg21242497

Using cf logs <app> –recent may provide some useful diagnostics after a crash even without the IBM_JAVA_OPTIONS environment variable set. If issued promptly, it may confirm that a crash and restart has occurred.

More stories

Announcing App ID integration to IBM Cloud Kubernetes Service

Today, we're excited to announce App ID integration with IBM Cloud Kubernetes Service. You can use this integration to enforce policy-driven security in a consistent way using declarative configuration of the Ingress Controller to add App ID protection for web applications, APIs, and back-ends. Using this approach, you don’t have to instrument each of your applications separately - all the authorization and authentication flows will be handled automatically for you. No code change is required!

Continue reading

Deploying to IBM Cloud Private 2.1.0.2 with IBM Cloud Developer Tools CLI

IBM Cloud Private is an application platform for developing and managing on-premises, containerized applications. It is an integrated environment for managing containers that includes the container orchestrator Kubernetes, a private image repository, a management console, and monitoring frameworks.

Continue reading

IBM Cloud Garage Method Field Guide

What does it mean to behave like a startup? How can you transform your business? Field-tested answers to these questions and others are found in the IBM Cloud Garage Method Field Guide. Presented in a fun and visual format, the Field Guide introduces the method and its related practices and architectures that you need to quickly develop quality products.

Continue reading