Hi there. I’m trying to get started deploying a completely bog standard Phoenix / Elixir app using Fly.io. I think I’m doing absolutely nothing outside the box, so I’m stumped as to what could be going wrong. What looks like is broken is that the app doesn’t start at port 8080 (despite it being defined in the fly.toml
file, which I have not edited by hand).
Github repo: GitHub - sgardn/fly_metapod: Phoenix / Elixir deployment on Fly.io
Elixir 1.16.0
Erlang 24.3.4.14
Phoenix 1.7.10
flyctl 0.1.147
Fly.toml
# fly.toml app configuration file generated for fly-metapod on 2024-02-02T12:07:55-05:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = 'fly-metapod'
primary_region = 'bos'
kill_signal = 'SIGTERM'
[build]
[deploy]
release_command = '/app/bin/migrate'
[env]
PHX_HOST = 'fly-metapod.fly.dev'
PORT = '8080'
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']
[http_service.concurrency]
type = 'connections'
hard_limit = 1000
soft_limit = 1000
[[vm]]
cpu_kind = 'shared'
cpus = 1
memory_mb = 1024
Launching
Running fly launch
with a boilerplate Phoenix app and attaching a minimal Postgres database during installation ends up showing me the following:
No machines in group app, launching a new machine
WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:
- 0.0.0.0:8080
Found these processes inside the machine with open listening sockets:
PROCESS | ADDRESSES
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*---------------------------------------
/app/erts-12.3.2.14/bin/beam.smp -- -root /app -progname erl -- -home /nonexistent -- -proto_dist inet6_tcp -- -noshell -s elixir start_cli -mode embedded -setcookie LOEBTJLCTZLK2TZ3ZXQDFTWON4D6QQNT5Y2NJDV4SQXOSBRPNOWQ==== -name fly-metapod-01HNNCN5DCF9BGB85XSZ26X5JQ@fdaa:2:d6eb:a7b:1ed:dc47:95c3:2 -config /app/releases/0.1.0/sys -boot /app/releases/0.1.0/start -boot_var RELEASE_LIB /app/lib -- -extra --no-halt | [::]:39359
/.fly/hallpass | [fdaa:2:d6eb:a7b:1ed:dc47:95c3:2]:22
/app/erts-12.3.2.14/bin/epmd -daemon | 0.0.0.0:4369, [::]:4369
Finished launching new machines
-------
NOTE: The machines for [app] have services with 'auto_stop_machines = true' that will be stopped when idling
-------
Checking DNS configuration for fly-metapod.fly.dev
Visit your newly deployed app at https://fly-metapod.fly.dev/
Logs
Running fly logs
shows me the following:
2024-02-02T17:14:33Z proxy[1852636a411d58] bos [info]Starting machine
2024-02-02T17:14:33Z app[1852636a411d58] bos [info][ 0.047000] PCI: Fatal: No config space access function found
2024-02-02T17:14:33Z app[1852636a411d58] bos [info] INFO Starting init (commit: bfa79be)...
2024-02-02T17:14:33Z app[1852636a411d58] bos [info] INFO Preparing to run: `/app/bin/server` as nobody
2024-02-02T17:14:33Z app[1852636a411d58] bos [info] INFO [fly api proxy] listening at /.fly/api
2024-02-02T17:14:33Z app[1852636a411d58] bos [info]2024/02/02 17:14:33 listening on [fdaa:2:d6eb:a7b:1ed:dc47:95c3:2]:22 (DNS: [fdaa::3]:53)
2024-02-02T17:14:33Z runner[1852636a411d58] bos [info]Machine started in 438ms
2024-02-02T17:14:34Z proxy[1852636a411d58] bos [info]machine started in 1.442739911s
2024-02-02T17:14:36Z app[1852636a411d58] bos [info]17:14:36.207 [notice] Application fly_metapod exited: FlyMetapod.Application.start(:normal, []) returned an error: shutdown: failed to start child: DNSCluster
2024-02-02T17:14:36Z app[1852636a411d58] bos [info] ** (EXIT) an exception was raised:
2024-02-02T17:14:36Z app[1852636a411d58] bos [info] ** (UndefinedFunctionError) function :net_kernel.get_state/0 is undefined or private
2024-02-02T17:14:36Z app[1852636a411d58] bos [info] (kernel 8.3.2.4) :net_kernel.get_state()
2024-02-02T17:14:36Z app[1852636a411d58] bos [info] (dns_cluster 0.1.2) lib/dns_cluster.ex:163: DNSCluster.warn_on_invalid_dist/0
2024-02-02T17:14:36Z app[1852636a411d58] bos [info] (dns_cluster 0.1.2) lib/dns_cluster.ex:84: DNSCluster.init/1
2024-02-02T17:14:36Z app[1852636a411d58] bos [info] (stdlib 3.17.2.4) gen_server.erl:423: :gen_server.init_it/2
2024-02-02T17:14:36Z app[1852636a411d58] bos [info] (stdlib 3.17.2.4) gen_server.erl:390: :gen_server.init_it/6
2024-02-02T17:14:36Z app[1852636a411d58] bos [info] (stdlib 3.17.2.4) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
2024-02-02T17:14:36Z app[1852636a411d58] bos [info] WARN Reaped child process with pid: 363 and signal: SIGUSR1, core dumped? false
2024-02-02T17:14:36Z app[1852636a411d58] bos [info] WARN Reaped child process with pid: 365 and signal: SIGUSR1, core dumped? false
2024-02-02T17:14:37Z app[1852636a411d58] bos [info]{"Kernel pid terminated",application_controller,"{application_start_failure,fly_metapod,{{shutdown,{failed_to_start_child,'Elixir.DNSCluster',{undef,[{net_kernel,get_state,[],[]},{'Elixir.DNSCluster',warn_on_invalid_dist,0,[{file,\"lib/dns_cluster.ex\"},{line,163}]},{'Elixir.DNSCluster',init,1,[{file,\"lib/dns_cluster.ex\"},{line,84}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,423}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}}},{'Elixir.FlyMetapod.Application',start,[normal,[]]}}}"}
2024-02-02T17:14:37Z app[1852636a411d58] bos [info]Kernel pid terminated (application_controller) ({application_start_failure,fly_metapod,{{shutdown,{failed_to_start_child,'Elixir.DNSCluster',{undef,[{net_kernel,get_state,[],[]},{'Elixir.DNSCluster',warn_on_invalid_dist,0,[{file,"lib/dns_cluster.ex"},{line,163}]},{'Elixir.DNSCluster',init,1,[{file,"lib/dns_cluster.ex"},{line,84}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,423}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}}},{'Elixir.FlyMetapod.Application',start,[normal,[]]}}})
2024-02-02T17:14:37Z app[1852636a411d58] bos [info]Crash dump is being written to: erl_crash.dump...done
2024-02-02T17:14:38Z app[1852636a411d58] bos [info] INFO Main child exited normally with code: 1
2024-02-02T17:14:38Z app[1852636a411d58] bos [info] INFO Starting clean up.
2024-02-02T17:14:38Z app[1852636a411d58] bos [info] WARN hallpass exited, pid: 307, status: signal: 15 (SIGTERM)
2024-02-02T17:14:38Z app[1852636a411d58] bos [info]2024/02/02 17:14:38 listening on [fdaa:2:d6eb:a7b:1ed:dc47:95c3:2]:22 (DNS: [fdaa::3]:53)
2024-02-02T17:14:39Z app[1852636a411d58] bos [info][ 6.296606] reboot: Restarting system
2024-02-02T17:14:39Z runner[1852636a411d58] bos [info]machine has reached its max restart count (10)
2024-02-02T17:14:40Z proxy[1852636a411d58] bos [info]waiting for machine to be reachable on 0.0.0.0:8080 (waited 5.560859277s so far)
2024-02-02T17:14:46Z proxy[1852636a411d58] bos [info]waiting for machine to be reachable on 0.0.0.0:8080 (waited 11.564189499s so far)
2024-02-02T17:14:51Z proxy[1852636a411d58] bos [error]failed to connect to machine: gave up after 15 attempts (in 16.568935362s)
Am I actually running into trouble with Erlang in net_kernel.get_state
? Or is that a red herring, and I’m actually seeing a healthcheck fail repeatedly because the server is running on the wrong port?