global trans & register

Roberto Ostinelli <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAFXp3LKn6TTj+yfmD+GbDSX0dnKhQnOinQ5rsPEKOK06E3gymg@mail.gmail.com>
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);

                _ ->
                    ok
            end
        end)

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,
r.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.