Start worker only on first instance

Hello,

I have an Elixir app which has some hard working background jobs. I only want to let them run on one node for the moment, the first one would be feasible. Is there a best practise how to do that?
As all instances share the same set of environment variable, I don’t see a good solution here.

This is an interesting problem. In the Rails world, you’d do this with two [processes]: Preview: multi process apps (get your workers here!)

That would probably work for your Elixir app too.

You could use postgres to elect a “leader” VM, but it’d take some work.

1 Like