How to gracefully shutdown a Phoenix App?

My project consists of an Umbrella app with two sub Phoenix apps. I use mix release to prepare the app and then dockerise it for AWS ECS deploys.

At the moment with each new version of the app, ECS will start the new container and once it determines the new container is healthy it retires the old version shortly after (I think it takes about a couple of minutes for the old container to get to the Stop state from Running).

It isn’t clear to me how ECS does this – i.e. does my app receive any signals to prepare for shutdown or not. So far I’ve not noticed anything wrong with how this happens but then the app isn’t in production use either. I wanted to ask here if anyone has tips or important steps that I should ensure the app takes before ECS container is shut down.

1 Like