One of my coworkers wrote a really cool bit of software to do this. I want him to open source it.
Basically, you can share a single socket amongst many servers. The OS ensures that just one process accepts each connection.
You can therefore have a manager process that owns the socket and passes it on to application processes.
To update, start new processes, then politely tell the old ones to go away.
One really cool thing in Linux is that you can actually pass file descriptors between processes over unix domain sockets.
Windows has supported this for ~14 years too.
Good to know. Does it work for everything that's an fd in Linux? I know you've got to treat sockets and files differently in some cases (or at least did once)...
It works for most kernel handles, sockets might be a little more normal starting with Win7 but I stopped doing Windows development around then.
Here are the official docs: http://msdn.microsoft.com/en-us/library/windows/desktop/ms72...
Looks like there's a separate function for sockets.
Still, cool stuff there too.
einhorn [1] implements this model and is pretty effective. Used in production at Stripe and other places. (It's written in Ruby, but can run application processes in any language.)
Re:What it's like to use Haskell
by DonPellegrino on Wednesday March 26, 2014 @11:13PM
(#7478364)
Basically, catch SIGINT, then stop listening to a socket/port. Finish all current requests and exit. The "watcher" parent process will restart the process with the new executable. Repeat for all other processes listening to the socket/port.
Re:What it's like to use Haskell
by shadytrees on Wednesday March 26, 2014 @07:50PM
(#7477558)
I can't answer for grandparent, but you should check out https://github.com/notogawa/graceful
Would you mind expanding on this a bit? I'm not too familiar with Haskell, but I am familiar with various was of blocking new connections while allowing existing connections to complete, either at the load-balancer level or built-in each individual process.
What Haskell stack are you using, and how are graceful restarts accomplished?
Thanks.