[99s-extend] Updating Cowboy applications

Joshua McQuistan joshua.mcquistan at mcq.io
Thu Mar 13 02:41:12 CET 2014


Hello all,

I have written a Cowboy application that works fine over localhost. I'm
now looking at ways of deploying and updating it i.e., moving from dev
to prod in a nice manner.

I have dug around the archives and have found that Cowboy does not
support hot code reloading meaning either a restart of the vm or playing
with code:reload_file is necessary.

The latter suggests a possible rewriting of OTP's code loading mechanism
and seems like it might be sensible to avoid.

The other approach then is a restart. In previous (non-Cowboy) set ups
I've used nginx on port 80 / 443 that talks to the web app via a unix
socket (e.g., "web/socket"). When updating I'll start a new instance on
a new socket (e.g., "web/socket.new") then rely on the file system's
"mv" to switch it to "web/socket"; this works because the underlying
file system guarantees mv to be atomic (or at least to never see a
missing file). I can then ask the old process to shut down nicely in the
background.

For this to work it would require Cowby / Ranch to be able to listen on
unix sockets. A glance at the documentation suggests that unix sockets
aren't available, is this the case? What's the feasibility of it getting
added?

It might just be simpler to load-balance across multiple servers and
safely take them out one at a time while updating.

My other question is, how do others approach this problem? Did I miss
something vitally obvious?

Regards,
Joshua



More information about the Extend mailing list