Introducing the Lifecycle Events
To get an introduction to the topic, watch the following video:
In the following section of this lesson, you'll discover more details about each event.
Restart
Restarting is a relatively low-impact operation designed to refresh the application’s operational state or recover it from minor issues, without changing the underlying code or configuration
Restarting Commands
- Restart all Instances
cf restart <app_name>
This command will destroy existing running container instances and create new ones, using the existing droplet and configuration.
- Restart Specific Instance
cf restart-app-instance <app_name> <instance_index>
This command targets only the specified instance, making it ideal for troubleshooting or minor fixes without affecting the overall application availability.
Restage
Restaging is necessary when environmental changes potentially alter the application's runtime behavior, despite the application code remaining unchanged. It's used when runtime dependencies change (for example, binding a new service, modifying environment variables, and so on), or when buildpacks or stacks are updated.
Restaging Command
cf restage <app-name>
This command integrates updated configurations or dependencies with the current code, effectively recompiling the application to reflect changes in the new droplet. It ensures that the application's functionality and performance align with the latest environment settings and service configurations.
Repush
Repushing is essential when the application code is modified, necessitating a full redeployment. It's useful for implementing new features, fixing bugs, or making other significant updates to the application.
Repushing Command
cf restage <app-name>
This command restarts the deployment process, creating a new droplet and starting the application anew. It ensures that all instances of the application are running the latest version of the code.
Crash
Cloud Foundry automatically attempts to restart a crashed instance up to 200 times, with increasing wait time between attempts. This process helps to minimize the impact of transient issues while allowing time for more persistent issues to be resolved.
Evacuation
In certain circumstances, such as platform updates or VM replacements, application instances may be relocated to different VMs in a process called evacuation. Cloud Foundry manages this process, creating duplicate instances on the new VM and ensuring they are fully operational before decommissioning the old instances
Shutdown
An application instance can be shut down either manually (using commands like cf stop) or automatically due to system events or failed health checks. SAP BTP, Cloud Foundry runtime sets a grace period of 10 seconds for the application to gracefully terminate before forcefully stopping it.
Summary
This lesson explores the essential lifecycle events in SAP BTP, Cloud Foundry runtime that impact application states, including maintenance operations like restart, restage, and repush, as well as system-managed events such as crash handling, evacuation, and shutdown. Understanding and managing these lifecycle events are crucial for maintaining robust, efficient, and scalable applications on SAP BTP, Cloud Foundry runtime
Tutorials
Use the Cloud Foundry Application Lifecycle for Buildpack Applications
Perform the following tutorial:Understand the Cloud Foundry application lifecycle for Buildpack applications
Use the Cloud Foundry Application Lifecycle for Docker Applications
Perform the following tutorial: Understand the Cloud Foundry application lifecycle for Docker applications