We are making distributed nodes of elixir application at EC2.
Reading running node names and connect them all together done via hex package https://github.com/kyleaa/libcluster_ec2.
The only work we have to do is to start a
named server in the release and set cookie.
We update file rel/env.sh.eex and put set global variables there, such as:
export RELEASE_NODE=<%= @release.name %>@IP
Finally our question:
- Is it proper way to get an IP of running instance?
- After we start
named server node (via ./prod/rel/app/bin/app start) we lost opportunity to connect to it via prod/rel/app/bin/app remote. An error is
Could not contact remote node app@IP, reason: :nodedown. Aborting...
We definitely doing something wrong, any advise appreciated )
I’m currently studying this fantastic example repo from https://github.com/bitwalker/distillery-aws-example for deploying distillery releases on EC2 instances. It is definitely a lot to take in at first, but I’ve tried to highlight the relevant parts for you below.
In this example, they are using: https://github.com/kelseyhightower/setup-network-environment
setup-network-environment is run as a systemd unit, it sets network info to several env vars, and it is configured to start before your elixir application here: https://github.com/bitwalker/distillery-aws-example/blob/master/rel/etc/distillery-example.service#L3
Then you can rely on
REPLACE_OS_VARS to set it in your vm.args file, ie: https://github.com/bitwalker/distillery-aws-example/blob/master/rel/vm.args#L3
we will try it, sounds like it may be easily done, i will give a feedback as we try