Re: global singleton gen_server
Roger Lipscombe <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAJgnQd9YwqZ0s9f3NnDjvGWV_ZVghRfrdDFjMHTkRh7Jdef_fw@mail.gmail.com> |
Define "cluster start". In normal operation, there's nothing stopping another node from joining the cluster at some arbitrary later time, even days later. The first node to come up is a degenerate, single node cluster, no? On Thu, 16 Dec 2021 at 11:00, Roberto Ostinelli <[email protected]> wrote: > > Dear all, > I'm trying to run an operation only once on cluster start but there's clearly something that I'm missing in the global module (see other related question here [1]). > > Therefore this time I'm trying to have a single global gen_server which I start directly from application start/2 callback with: > gen_server:start_link({global, ?MODULE}, ?MODULE, [], Options). > > Nodes are already connected at that point (I can see them with nodes()), however for some reason this registration works on all the nodes and I find myself with multiple gen_server registered globally. > > What is the proper way to register a global singleton gen_server at cluster level on application start? mY need is to run an operation only _once_ a cluster boots up. > > [1] http://erlang.org/pipermail/erlang-questions/2021-December/101781.html