TIL: Deploying Elixir Apps with Distillery

Out of the many positives of Erlang, the biggest being the light weight processes and a functional programming model coupled with immutability, the ability to do hot-reloads of the server (Yes, you don’t need a restart of the server daemon!). Doing this in Erlang is quite cumbersome but tools like exrm take a lot of pain out of this. However, distillery takes this one step further.

Creating a new update for your Elixir project using distillery is as simple as running …

$ MIX_ENV=prod mix release --upgrade

For a full brown amazing tutorial on the setup, detailed step-by-step walkthrough and the gotchas, go here.

A tiny note of caution: The tutorial works fine for the first upgrade (i.e going from 0.1.0-> 0.2.0) but not for the later upgrades (0.2.0-> 0.3.0). To have the workflow for continuous deployment work, have the build and the deployment in separate locations.

The gist below however will serve as a quick reference material for

  • setting up distillery & initializing the release mechanism
  • building a upgrade archive
  • deploying it to a production location
  • downgrade to a previous version if needed

Note: Most of the times it is not worth the hassle to handle releases in this method – a standard restart would work fine in most cases, however having a good release management system system will force one to think through the impact of the upgrade or downgrade. However, it is worth pondering over to understand the impact of measured upgrades for servers in the same way that database migrations work for schema and application server changes.

Tagged: Tags

Leave a Reply

Your email address will not be published. Required fields are marked *