Phoenix 1.6.10 app, works fine locally.
When I run fly launch
everything seems to deploy fine and database migrations complete successfully but the launch eventually fails with the following errors:
***v0 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v1
Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort
Log file says the following:
Waiting for logs...
2022-06-15T22:40:11.143 app[2faf9e99] lhr [info] Crash dump is being written to: erl_crash.dump...done
2022-06-15T22:40:11.148 app[2faf9e99] lhr [info] Reaped child process with pid: 575 and signal: SIGUSR1, core dumped? false
2022-06-15T22:40:12.150 app[2faf9e99] lhr [info] Main child exited normally with code: 1
2022-06-15T22:40:12.151 app[2faf9e99] lhr [info] Starting clean up.
2022-06-15T22:40:19.297 runner[2faf9e99] lhr [info] Starting instance
2022-06-15T22:40:19.550 runner[2faf9e99] lhr [info] Configuring virtual machine
2022-06-15T22:40:19.551 runner[2faf9e99] lhr [info] Pulling container image
2022-06-15T22:40:19.969 runner[2faf9e99] lhr [info] Unpacking image
2022-06-15T22:40:19.988 runner[2faf9e99] lhr [info] Preparing kernel init
2022-06-15T22:40:20.298 runner[2faf9e99] lhr [info] Configuring firecracker
2022-06-15T22:40:20.411 runner[2faf9e99] lhr [info] Starting virtual machine
2022-06-15T22:40:20.590 app[2faf9e99] lhr [info] Starting init (commit: e21acb3)...
2022-06-15T22:40:20.613 app[2faf9e99] lhr [info] Preparing to run: `/app/bin/server` as nobody
2022-06-15T22:40:20.636 app[2faf9e99] lhr [info] 2022/06/15 22:40:20 listening on [fdaa:0:6842:a7b:2808:2faf:9e99:2]:22 (DNS: [fdaa::3]:53)
2022-06-15T22:40:21.619 app[2faf9e99] lhr [info] Reaped child process with pid: 554, exit code: 0
2022-06-15T22:40:23.155 app[2faf9e99] lhr [info] =INFO REPORT==== 15-Jun-2022::22:40:23.152807 ===
2022-06-15T22:40:23.155 app[2faf9e99] lhr [info] Can't set long node name!
2022-06-15T22:40:23.156 app[2faf9e99] lhr [info] Please check your configuration
2022-06-15T22:40:23.159 app[2faf9e99] lhr [info] SUPERVISOR REPORT==== 15-Jun-2022::22:40:23.156852 ===
Research seems to indicate that this might be about the hostname of the server and whether it is fully qualified or not, but I don’t know how to control this.
Any ideas?
Do you have a rel/env.sh.eex
file, if yes, how does it look like?
1 Like
This is an Erlang error saying that you’re trying to start a named node without a fully qualified name. How did you build this deployment? With a heroku buildpack, or with mix release? Knowing what steps you followed and the contents of your rel/
directory if you have one might help
Edit: @sysashi is right, it would be the rel/env.sh.eex
file specifically if you have one
1 Like
Thanks for your help.
Here’s my rel/env.sh.eex
file. It was auto-generated by some version of Phoenix—all I changed was to try un-commenting the
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=<%= @release.name %>
lines, but it didn’t change the error.
#!/bin/sh
# Sets and enables heart (recommended only in daemon mode)
# case $RELEASE_COMMAND in
# daemon*)
# HEART_COMMAND="$RELEASE_ROOT/bin/$RELEASE_NAME $RELEASE_COMMAND"
# export HEART_COMMAND
# export ELIXIR_ERL_OPTIONS="-heart"
# ;;
# *)
# ;;
# esac
# Set the release to work across nodes.
# RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=<%= @release.name %>
#!/bin/sh
ip=$(grep fly-local-6pn /etc/hosts | cut -f 1)
export RELEASE_DISTRIBUTION=name
export ELIXIR_ERL_OPTIONS="-proto_dist inet6_tcp"
All I did was to run fly launch
in the root directory of my Phoenix app (which works fine in dev mode).
try changing the file contents to:
#!/bin/sh
# Sets and enables heart (recommended only in daemon mode)
# case $RELEASE_COMMAND in
# daemon*)
# HEART_COMMAND="$RELEASE_ROOT/bin/$RELEASE_NAME $RELEASE_COMMAND"
# export HEART_COMMAND
# export ELIXIR_ERL_OPTIONS="-heart"
# ;;
# *)
# ;;
# esac
# Set the release to work across nodes.
# RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
ip=$(grep fly-local-6pn /etc/hosts | cut -f 1)
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE=$FLY_APP_NAME@$ip
export ELIXIR_ERL_OPTIONS="-proto_dist inet6_tcp"
These are the lines that set your node name type and value.
export RELEASE_DISTRIBUTION=name
will use the --name
option for a long name (compared to --sname
for short name)
export RELEASE_NODE=$FLY_APP_NAME@$ip
for the name value e.g. my-app@______ip_address______
This looks like the Elixir templating language Eex
somehow leaked into the generated file from the source code, I’m not sure why that might have happened though
1 Like
That worked, or at least it got me to the next error, but this one is clearly a fault in my application (missing file) rather than any deployment issue.
Thank you so much, I really appreciate it.
Out of curiosity, how do you think I got here? I’m sure that I never touched this file until just yesterday to try the edit I mentioned. A case of a bug in a previous version of Phoenix?
1 Like
Great! So I was curious if there was a bug or what happened, as it’s been a minute since I’ve run these commands myself. I looked at the source code and generated a brand new 1.6.10 app to see what comes out.
The file is generated by the command mix release.init
, and the default contents are:
#!/bin/sh
# Sets and enables heart (recommended only in daemon mode)
# case $RELEASE_COMMAND in
# daemon*)
# HEART_COMMAND="$RELEASE_ROOT/bin/$RELEASE_NAME $RELEASE_COMMAND"
# export HEART_COMMAND
# export ELIXIR_ERL_OPTIONS="-heart"
# ;;
# *)
# ;;
# esac
# Set the release to work across nodes.
# RELEASE_DISTRIBUTION must be "sname" (local), "name" (distributed) or "none".
# export RELEASE_DISTRIBUTION=name
# export RELEASE_NODE=<%= @release.name %>
This is a template though, when you run mix release
it will inject the configured release name into <%= @release.name %>
. The code is commented and will not run by default, and may need further customizing to work.
Somehow, you also ended up with this at the end of your file
#!/bin/sh
ip=$(grep fly-local-6pn /etc/hosts | cut -f 1)
export RELEASE_DISTRIBUTION=name
export ELIXIR_ERL_OPTIONS="-proto_dist inet6_tcp"
Maybe you copied it from a guide? Here you were setting the --name
option without actually providing a name, because # export RELEASE_NODE=<%= @release.name %>
was commented. However uncommenting the line still did not fix it because <%= @release.name %>
resolves to my_app
, which is only a default based on your app name and lacks the IP address to make it a fully qualified name for the --name
option. So, this needs a little more customizing for it to work. The solution can be found in the official Phoenix fly.io deployment guide, specifically in this section.
It should be noted that these extra steps with mix release.init
are not necessary to deploy on fly.io, and are only necessary if you’re clustering your application, but that’s why most of us are deploying on fly.io in the first place