IBM Cloud Docs
Why did my app restart?

Why did my app restart?

My app is running, but I see that app instances are restarted.

When an application restart occurs, Code Engine automatically starts a new instance of the app. When your new app instance is marked as Ready, Code Engine routes traffic to it.

If your app is restarted, determine whether one of the following cases is true.

  1. An exception has occurred and it is not handled in your application source code.

  2. Your Code Engine system memory configuration is constrained for resources. For example, the memory setting per instance is set too low, so the instance experiences restarts due to out of memory errors. Or, the ephemeral storage limit is reached.

  3. Because Code Engine is a fully managed IBM Cloud environment, applications, and other Code Engine workloads might get relocated to another physical location; for example, to apply security fixes. Given the managed nature of the environment, these types of changes can occur at any time. When you are working with deployed applications, actions of this type can cause your application to restart.

    During times of maintenance, a running application instance is relocated, meaning that the running instance is deleted and a new one created. When this happens the restart count is reset to 0. The age of the app instance is a good indicator of this scenario.

Try one of these solutions.

  1. If an exception occurred, take the following actions.

    • Check for messages that might help you determine what is happening. If you set up logging for Code Engine, your log files might contain messages. For more information about logging, see Viewing logs.
    • After you update your application source code and build an updated container image, create a new revision for your app by updating your application.
    • Use the detailed views of your application instances to help you in troubleshooting your apps. Use the Code Engine console to view details of your app instances. See Getting details about app instances.
  2. If your application is constrained for memory resources, take the following actions.

  3. In general, you cannot rely on specific application instances to run without interruption in the managed Code Engine environment. You can make sure that your app follows the 12-factor app methodology to avoid downtime with your app during these types of system upgrades. See Why did my app stop running?