4 ms·
Is there any kind of generalization of this approach that can be used for hot-swapping other servers with persistent connections?
by jasonthorsness 2y ago
Is there any kind of generalization of this approach that can be used for hot-swapping other servers with persistent connections?
- celdon25 2y agoSometimes. You may be able to identify a category of customizations that has both a high frequency, and the potential to be represented as declarative data. Changes to the data can be done without a restart. That can often be enough to get by. But in my experience (which may vary from your own), this takes significant investment and you’d need a very strong incentive or it would need to be a passion project of some sort.
- toast0 2y agoI mean, this technique seems pretty general already? Get a signal, do the thing (fork, then exec, then copy state, then you're done). But, there's other options. If you want to keep long running connections, but there's not really shared state, you can just fork and then move the socket to the new server and let the old one drain out and exit when it's done/ after you waited long enough. Using a BEAM language like Erlang or Elixir gives you hotloading as a fundamental tool, and otp has some suggestions for how you could use that. You can do hotloading in C with dlopen and dlsym/dlfunc, but you've got to structure your code carefully to make it work, and you may be stuck with a fixed outer loop, depending on how creative you are at writing weird C. Java has hotloading too, at least in some vms. I've built hotloading in Perl, but I don't think I'd be proud of my code if I looked at it again.