Container Recovery
When Containers on Aptible exit unexpectedly (i.e., Aptible did not terminate them as part of a deploy or restart), they are automatically restarted. This feature is called Container Recovery. For most apps, Aptible will automatically restart containers in the event of a crash without requiring user action.
Overview
When Containers exit, Aptible automatically restarts them from a pristine state. As a result, any changes to the filesystem will be undone (e.g., PID files will be deleted, etc.). As a user, the implication is that if a Container starts properly, Aptible can automatically recover it. To modify this behavior, see Disabling filesystem wipes below.
Whenever a Container exits and Container Recovery is initiated, Aptible logs the following messages and forwards them to your Log Drains. Note that these logs may not be contiguous; there may be additional log lines between them.
If you wish to set up a log-based alert whenever a Container crashes, we recommend doing so based on the string container recovery initiated
. This is because the lines container has started
and container has exited
will be logged during the normal, healthy Release Lifecycle.
If an App is continuously restarting, Aptible will throttle recovery to a rate of one attempt every 2 minutes.
Cases where Container Recovery will not work
Container Recovery restarts Containers that exit, so if an app crashes but the Container does not exit, then Container Recovery can’t help.
Here’s an example Procfile demonstrating this issue:
In this case, since my-app
is running in the background, the Container will not exit when my-app
exits. Instead, it would exit if tail
exited.
To ensure Container Recovery effectively keeps an App up, make sure that:
- Each Container is only running one App.
- The one App each Container is supposed to run is running in the foreground.
For example, rewrite the above Procfile like so:
Use a dedicated process manager in a Container, such as Forever or Supervisord, if multiple processes need to run in a Container or something else needs to run in the foreground.
Contact Aptible Support when in doubt.
Disabling filesystem wipes
Container Recovery automatically restarting containers with a pristine filesystem maximizes the odds of a Container coming back up when recovered and mimics what happens when restarting an App using aptible restart
.
Set the APTIBLE_DO_NOT_WIPE
Configuration variable on an App to any non-null value (e.g., set it to 1
) to prevent the filesystem from being wiped (assuming it is designed to handle being restarted properly).
Was this page helpful?