I think this makes sense. So, to summarise all of this:
- Add a supervisor process such as hivemind/overmind
- This supervisor is the glue between
litefs mount
andbackend
andworker
processes - Whenever a deployment happens, if the node is the primary node after
litefs mount
has run (as known by the litefs exec), then we run the migrations, after which we run a script which starts the supervisor. This script will always startbackend
but will only startworker
if the node is the primary - Whenever a node gets elected as primary after a deployment, this is broadcasted as a
primaryChange
as per the LiteFS event stream, and the supervisor can act accordingly by killing/starting theworker
on that node. This is done by a script, which is also run by the supervisor? Or where does this fit?
Thoughts?
I feel like I’m quite far away from my comfortable frontend devving at this point