Failed deployment v5 Failed due to unhealthy allocations - no stable job version to auto revert to.


prod.exs

use Mix.Config

# For production, don't forget to configure the url host
# to something meaningful, Phoenix uses this information
# when generating URLs.
#
# Note we also include the path to a cache manifest
# containing the digested version of static files. This
# manifest is generated by the `mix phx.digest` task,
# which you should run after static files are built and
# before starting your production server.
config :fchatapp, FchatappWeb.Endpoint,
  url: [host: "chatapp.com", port: 80],
  cache_static_manifest: "priv/static/cache_manifest.json"


secret_key_base =
 "secret-key"

app_name =
 "chatapp"

#database_url =
#  System.get_env("DATABASE_URL") ||
#    raise """
#    environment variable DATABASE_URL is missing.
#    For example: ecto://USER:PASS@HOST/DATABASE
#    """

#config :fchatapp, Fchatapp.Repo,
#       username: "postgres",
#       password: "PASSWORD",
#       database: "chatapp_prod",
#       hostname: " chatapp-db.internal",
#       show_sensitive_data_on_connection_error: true,
#       pool_size: 10
#config :fchatapp, Fchatapp.Repo,
#       url: "postgres://postgres:PASSWORD@chatapp-db.internal:5432/chatapp-db",
#         # DON'T FORGET THE FOLLOWING LINE
#       socket_options: [:inet6],
#       pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

config :fchatapp, Fchatapp.Repo,
       username: "msehuzgynmwzfy",
       password: "PASSWORD",
       database: "DB",
       hostname: "HOST",
       show_sensitive_data_on_connection_error: true,
       pool_size: 10,
       ssl: true

config :fchatapp, FchatappWeb.Endpoint,
       server: true,
       secret_key_base: secret_key_base,
       load_from_system_env: true,
       http: [port: {:system, "PORT"}],
       url: [scheme: "https", host: "#{app_name}.fly.dev", port: 443],
       force_ssl: [rewrite_on: [:x_forwarded_proto]],
       cache_static_manifest: "priv/static/cache_manifest.json"

config :fchatapp, FchatappWeb.Endpoint,
       live_reload: [
            patterns: [
                 ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
                 ~r"priv/gettext/.*(po)$",
                 ~r"lib/fchatapp_web/(live|views)/.*(ex)$",
                 ~r"lib/fchatapp_web/templates/.*(eex)$",
                 ~r{lib/phat_web/live/.*(ex)$}
            ]
       ]

# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"

# Do not print debug messages in production
config :logger, level: :info

# ## SSL Support
#
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
#     config :fchatapp, FchatappWeb.Endpoint,
#       ...
#       url: [host: "example.com", port: 443],
#       https: [
#         port: 443,
#         cipher_suite: :strong,
#         keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"),
#         certfile: System.get_env("SOME_APP_SSL_CERT_PATH"),
#         transport_options: [socket_opts: [:inet6]]
#       ]
#
# The `cipher_suite` is set to `:strong` to support only the
# latest and more secure SSL ciphers. This means old browsers
# and clients may not be supported. You can set it to
# `:compatible` for wider support.
#
# `:keyfile` and `:certfile` expect an absolute path to the key
# and cert in disk or a relative path inside priv, for example
# "priv/ssl/server.key". For all supported SSL configuration
# options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1
#
# We also recommend setting `force_ssl` in your endpoint, ensuring
# no data is ever sent via http, always redirecting to https:
#
#     config :fchatapp, FchatappWeb.Endpoint,
#       force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.

# Finally import the config/prod.secret.exs which loads secrets
# and configuration from environment variables.
#import_config "prod.secret.exs"

config/release.exs

use Mix.Config

#secret_key_base =
#  System.get_env("SECRET_KEY_BASE") ||
#    raise """
#    environment variable SECRET_KEY_BASE is missing.
#    You can generate one by calling: mix phx.gen.secret
#    """
#
#app_name =
#  System.get_env("FLY_APP_NAME") ||
#    raise "FLY_APP_NAME not available"
secret_key_base =
  "KEY_BASE"

app_name =
  "chatapp"
#database_url =
#  System.get_env("DATABASE_URL") ||
#    raise """
#    environment variable DATABASE_URL is missing.
#    For example: ecto://USER:PASS@HOST/DATABASE
#    """
#config :fchatapp, Fchatapp.Repo,
#       url: "postgres://postgres:PASSWORD@chatapp-db.internal:5432/chatapp-db",
#         # DON'T FORGET THE FOLLOWING LINE
#       socket_options: [:inet6],
#       pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
config :fchatapp, Fchatapp.Repo,
       username: "USER",
       password: "PASSWORD",
       database: "DB",
       hostname: "HOST",
       show_sensitive_data_on_connection_error: true,
       pool_size: 10,
       ssl: true


#config :fchatapp, Fchatapp.Repo,
#       username: "postgres",
#       password: "PASSWORD",
#       database: "chatapp_prod",
#       hostname: " chatapp-db.internal",
#       show_sensitive_data_on_connection_error: true,
#       pool_size: 10


#config :fchatapp, Fchatapp.Repo,
#       url: database_url,
#         # DON'T FORGET THE FOLLOWING LINE
#       socket_options: [:inet6],
#       pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

config :fchatapp, FchatappWeb.Endpoint,
       server: true,
       secret_key_base: secret_key_base,
       load_from_system_env: true,
       http: [port: {:system, "PORT"}],
       url: [scheme: "https", host: "#{app_name}.fly.dev", port: 443],
       force_ssl: [rewrite_on: [:x_forwarded_proto]],
       cache_static_manifest: "priv/static/cache_manifest.json"

config :fchatapp, FchatappWeb.Endpoint,
       live_reload: [
         patterns: [
           ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
           ~r"priv/gettext/.*(po)$",
           ~r"lib/fchatapp_web/(live|views)/.*(ex)$",
           ~r"lib/fchatapp_web/templates/.*(eex)$",
           ~r{lib/phat_web/live/.*(ex)$}
         ]
       ]

# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"

lib/fchatapp/release.ex

defmodule Fchatapp.Release do
  @moduledoc """
  Used for executing DB release tasks when run in production without Mix
  installed.
  """
  @app :fchatapp

  def migrate do
    load_app()

    for repo <- repos() do
      {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
    end
  end

  def rollback(repo, version) do
    load_app()
    {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
  end

  defp repos do
    Application.fetch_env!(@app, :ecto_repos)
  end

  defp load_app do
    Application.load(@app)
  end
end

terminal output

--> Pushing image done
Image: registry.fly.io/chatapp:deployment-1646405131
Image size: 103 MB
         Starting instance
         Pulling container image
         Preparing kernel init
         Starting virtual machine
         Preparing to run: `/app/bin/migrate` as nobody
         [    0.116079] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
         [    0.118104] Call Trace:
         [    0.119028]  dump_stack+0x6b/0x86
         [    0.120087]  do_exit.cold+0x60/0xb0
         [    0.121273]  __x64_sys_exit_group+0x18/0x20
usama@Usamas-MacBook-Pro chatapp % 

I strongly suggest you stop publishing the secrets in your configs. Unless of course, the data or compromise of the data or connections is not important.

I’m also not sure what you want me to do with it.

Have you tried checking the logs? fly logs

In your prod.exs file, this is commented out:

#         # DON'T FORGET THE FOLLOWING LINE
#       socket_options: [:inet6],

You didn’t include the Phoenix or Elixir versions here. I’m assuming from some of your previous posts that this is not being deployed the new way, but instead using the old way. But that’s not clear either.

If you are following the older directions for Phoenix projects created pre-1.6.3, the it is important to configure inet6 for the connection to the database. That is, if the database is a Fly.io hosted database.

Based on your configs, it looks like you are trying to connect to a database in AWS. Is that even possible given the network settings on AWS?

If you are trying to debug the ability to deploy an Elixir app on Fly that connects to a Fly Postgres DB, then I’d suggest downloading one of the sample Elixir applications and see if that deploys for you. That can help you isolate where your config problems are.