Based on https://elixir-lang.org/getting-started/mix-otp/task-and-gen-tcp.html example, I am writing small websocket server. No Phoenix or Cowboy, just low level Elixir, Task.Supervisor and :gen_tcp. All the protocols are ready/tested so I have very lean and agile PubSub server without all the overlays.
When I use Distillery, generate 0.1.0, start the server, then generate 0.1.1 and upgrade, all the existing connection tasks are killed, which is not optimal with long living tasks/tcp connections with websocket protocol.
I am aware that GenServer offers some automation during upgrade but I don’t know yet if it kills the processes too and migrates data to new version or does some other magic – didn’t rewrite my connection tasks into GenServer and would love to avoid that, plus I am not sure if that would preserve existing connections.
It would save me some time if some kind soul can answer few questions
Using Distillery upgrade process, if I rewrite existing tasks into GenServers, would they retain existing websocket connections?
What happens (low level) during upgrade? Are there messages swishing around or processes just get killed?
Is there any chance to keep using tasks (not even Agents) to serve websockets and write them in a way to survive upgrade process? It is perfectly OK for existing tasks to keep running until user closes connection and use new version for all new connections – just no idea how to do it.
How do I pack or invoke :observer with production build using Distillery? Having observer to see what’s actually going on during update would help a lot.