So I’ve been trying the new Elixir 1.9 releases in order to move from using Distillery & edeliver (nothing wrong with any of those though).
One thing I’m now struggling with is defining Nodes to connect to. In Erlang what I see used is making a config file, that is static in nature. I’ve seen some examples starting the repl, and passing -config dir/name
to it to load that config file.
On the Elixir release wrapper, there seems to be some ways to hook up into the boot process just before it starts the app. So I was imagining I could do something like
defmodule TestProvider do
@behaviour Config.Provider
def init(_), do: nil
def load(config, nil) do
:inets.start
{:ok, {_, _, resp} = some_response = :httpc.request('http://www.erlang.org')
Config.Reader.merge(
config,
web: [
some_value: resp
]
)
end
end
This does set config for the app web
-> some_value
to resp and works correctly. But what format should I use to set something like the following Erlang tuple?
[
{kernel, [
{distributed, [{web, 5000, [a@host, {b@host, c@host}]}]},
{sync_nodes_mandatory, [b@host, c@host]},
{sync_nodes_timeout, 30000}
]
}
].
(shamelessly copied from learnyousomeerlang.com)
Or if that doesn’t work / isn’t possible, how could I write this to a file to be used by the release on the boot after the config dry-run? Where should I write this file to?
Can I then pass -config some_path
to the app boot through env.sh
and set there
export ELIXIR_ERL_OPTIONS="-config some_path"
?
Thanks