How to prevent a node becoming distributed if started by a release?

Once my application starts, I want to talk to Consul to figure out other running nodes and connect them into a cluster. I want to customize my node’s longname and cookie.

The problem seems to be that the node is automatically started as a distributed node since I’m using releases. Therefore I can’t use :net_kernel.start (already started) nor :net_kernel.stop (not allowed).

Is there a way to do it? Or do I need to put all the logic into the env.sh?

Have you looked at https://github.com/bitwalker/libcluster ? You may need a custom strategy module if you implement some non standard deployment, but it should be flexible enough to what you are trying to do.

Yes, I did. In the long run I might use libcluster, but I think my problem is that I need to reconfigure the node distribution after it’s booted, but before I let libcluster cluster the nodes.

Looks like I found the reason:

 {elixir,
     [{config_providers,
          #{'__struct__' => 'Elixir.Config.Provider',
            config_path => {system,<<"RELEASE_SYS_CONFIG">>,<<".config">>},
            extra_config => [{kernel,[{start_distribution,true}]}],
            providers =>
                [{'Elixir.Config.Reader',
                     {system,<<"RELEASE_ROOT">>,
                         <<"/releases/0.1.0/releases.exs">>}}],
            prune_after_boot => false}}]},
 {kernel,[{start_distribution,false}]}].

[{kernel,[{start_distribution,true}]}] is once specified with false, once with true. If I change both to false the node is not started as distributed.

Why is this the case? Can I safely change this? How do I configure this not to be set to true without fiddling with sys.config?

I think setting start_distribution to false won’t allow you to start it properly later. If you do try to allow it, the system will be in a borked state with missing components.

This feature is not supported by Elixir releases, so please open up an issue. We should add support for something like RELEASE_DISTRIBUTION=noname.

3 Likes

Thanks, issue created.