global trans & register

Roberto Ostinelli ostinelli@REDACTED
Wed Dec 15 23:02:51 CET 2021

Dear list,
I'm trying to run some code only once when the first node starts a cluster.
I'm using at the beginning of the app:

  Self = self(),
  global:trans({?MODULE, ?MODULE},
        fun() ->
            case global:whereis_name(my_flag) of
                undefined ->
                    error_logger:info_msg("RUN ON ~p", [node()]),
                    global:register_name(my_flag, Self);

                _ ->

The result is that RUN ON XX is in every cluster node log.

Can some kind soul tell me what I'm missing?

Thank you,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the erlang-questions mailing list