Why did my app stop running?
After you deploy an app, the app runs for a while and then ends unexpectedly.
Determine whether one of the following cases is true.
- Your app code includes an exit when it completes its running cycle.
- Your app code contains an error that is causing the app to end unexpectedly.
- The image that your app is pulling from no longer exists because you deleted it or your image retention policy in IBM Cloud Container Registry caused it to be deleted. For example, your app is scaling up because of incoming requests. However, the scale-up fails because the image no longer exists in Container Registry. Another typical situation is if your app is on a worker node that is scheduled to receive the latest security fixes. If Code Engine attempts to move your app to a different worker node and cannot find the image, the move fails and the app stops working.
- The image that your app is pulling from no longer exists because while the image with the provided tag exists, it was overwritten after an application revision was created. The image that is associated with your specific application revision uses a unique container registry digest, and this digest is used for the life of your application revision. If you create a newer version of the image with the same tag as the original image, the original image is overwritten in the container registry. However, Code Engine cannot find this newer image, because the newer image has a different digest than the digest for the application revision. No new instances of the application can be created, and this scenario results in a failure of the application.
Try the following solutions to resolve your problem.
-
Code Engine apps are designed to run without exiting. If your app code includes an exit, then consider running your code as a job instead.
-
Check for messages that might help you determine the cause. If you set up logging for Code Engine, your log files might contain messages. For more information about logging, see Viewing logs. Your app must follow 12-factor app methodology. For example, if the underlying structure of Code Engine that your app is running on requires an update, then a new instance of your app is created on the updated infrastructure. When your new app instance is marked as
Ready
, Code Engine routes traffic to it. Your old app then receives aSIGTERM
message, allowing time for it to shut down safely. If it does not shut down, then Code Engine sends aSIGKILL
message and your old app instance is destroyed, which can cause data to be lost. -
Re-create the image in Container Registry and then deploy another instance of your app. Then, check your image retention policy in Container Registry so that images that are used by active revisions are not deleted. If you are using toolchain templates for Code Engine, you can also add logic to your pipeline definition to delete unused versions of your image only after a working version is deployed.
-
Create a new revision for your app by updating your application. If an image is pushed with same tag, then you must update your application to create a new revision that uses this updated image.