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.
-
An exception has occurred and it is not handled in your application source code.
-
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.
-
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.
-
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.
-
If your application is constrained for memory resources, take the following actions.
- Be aware of Code Engine limits. See Limits and quotas for Code Engine. If needed, update your application to change the memory settings for your app.
- Check the resource settings for your app and modify as needed. See Options for deploying an app.
- 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.
-
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?