What is the current approach to doing hot code reloading?

I’m trying to use hot code reloading in my app. The app in question is deployed using mix releases.

As I understand it, there was once a project called Distillery, but it is now dead - most of functionality was merged into mix release. Howerver, the hot code reloading support didn’t survive the migration - according to the docs Distillery was capable of generating appup files, but now I failed to find any tools that could do anything like that. Seems that the only remaining route is to write the appups myself.

Are there any known tools that simplify the task of writing appup files? Or does everyone write the appup files by hand?

P.S. By the way, I’ve read about and am aware of many issues and pitfalls that await unlucky souls that are going down the hot code reload path. But in my particular case, the application is maintaining a significant number of stateful connections, and it will be very nice if these connections can be preserved, if possible. And the upgrades aren’t expected to be very difficult - most of the processes are using GenServers, state is kept in maps, etc.
I understand that many suggest using blue/green deployments and docker and whatever, but I think that there’s some middle ground to be had - I can always go the blue/green road if some particular upgrade is difficult to do with hot reloading, but in most of simpler cases I can save lots of pain by simply loading the updated modules.
As someone said, “there’s a distinction between relying on hot deploys and simply enjoying them”.

3 Likes

There is castle previously announced here. It does integrate with mix releases, but does not do appup generation.

2 Likes

I saw castle. However, I was a bit worried that it’s unmaintained - it has only a brief surge of commits for a week after its inception, and then nothing.

In the end I decided to skip the castle - just inserted an additional step intomix release and used :release_handler directly.

However, castle code was very useful for understanding what tweaks were needed - thanks for releasing it!

2 Likes

@rogach can you please share your config ? I might need it as well for one of my projects and would like to see your implementation. Thanks

Here’s what I ended up with: How to: Tweak mix release to work with hot code reloading

Don’t hesitate to ask questions if I forgot to detail something :slight_smile:

4 Likes