I have a simple application that listens for web hook events which start up a new process under a dynamic supervisor, this process opens a port to execute a shell script. I have everything working as a standalone package but the problem I’m trying to solve is keeping the dynamic supervisor (and it’s processes) running when the web application is restarted on deployment.
I started by moving my application into an umbrella app with 2 releases. The first release is for the web interface (listens for the web hooks) and the second release contains the application that starts the dynamic supervised processes which I’ve called operations. I’m approaching it this way so that I can restart the web release without touching the operations release.
I’ve thrown together a minimal repository that showcases where I am at hendore/node-comms with this.
The part I’m struggling with is finding the right way to communicate between the two nodes running these releases. I want the web node to be able to start builds via the operations node, it turns out from what I know I can use either
- Node.spawn(:operations@hostname, fn -> Builder.start_build("…") end)
- :rpc.call(:operations@hostname, Builder, :start_build, ["…"])
- Rewrite the builder application to use a Task.Supervisor instead of DynamicSupervisor and use
I’m just wondering what would be the best method for tackling this problem, ideally I would also like to subscribe to changes from the web node and have the operations node publish changes via pubsub, so maybe i could just use pubsub to tell the operations node to start a new build too?