bitwalker / distillery

Simplify deployments in Elixir with OTP releases!
MIT License
2.96k stars 396 forks source link

Appending sname/name with hostname is not in sync with Erlang #714

Open lukyanov opened 4 years ago

lukyanov commented 4 years ago

Steps to reproduce

  1. Set -name in vm.args as foo (without @).
  2. Build the release.

Description of issue

The issue is this. Erlang relies on a fully qualified host name when appending the node name. Distillery, however, relies on $HOSTNAME to do the same. This may result to situations when commands like remote_console won't work. The example of such a situation would be a host with no DNS name setup: Erlang translates foo to foo@1.2.3.4, but distillery - to foo@hostname.

The expected result would be to use the same appending mechanism that Erlang does. Erlang seems to rely on what the command hostname -f returns.

Suggested fix:

--- a/priv/libexec/helpers.sh
+++ b/priv/libexec/helpers.sh
@@ -48,7 +48,7 @@ gen_nodename() {
 get_hostname() {
     host="$(echo "${NAME}" | cut -d'@' -f2 -s)"
     if [ -z "$host" ]; then
-        echo "${HOSTNAME}"
+        /bin/hostname -f
     else
         echo "$host"
     fi