--> v3 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v4

Not sure how to figure out whats the error how to debuge

--> Pushing image done
image: registry.fly.io/chatapp:deployment-1646451888
image size: 123 MB
         Starting instance
         Pulling container image
         Preparing kernel init
         Starting virtual machine
         Preparing to run: `/app/bin/migrate` as nobody
         Reaped child process with pid: 564 and signal: SIGUSR1, core dumped? false
         Main child exited normally with code: 0
==> Monitoring deployment
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
 1 desired, 1 placed, 0 healthy, 1 unhealthy [health checks: 1 total, 1 critical]
Failed Instances

Failure #1

Instance
ID              PROCESS VERSION REGION  DESIRED STATUS  HEALTH CHECKS           RESTARTS        CREATED   
c91a829e                3       cdg     run     running 1 total, 1 critical     0               4m55s ago       

Recent Events
TIMESTAMP               TYPE            MESSAGE                 
2022-03-05T03:48:24Z    Received        Task received by client 
2022-03-05T03:48:24Z    Task Setup      Building Task Directory 
2022-03-05T03:48:32Z    Started         Task started by client  

2022-03-05T03:48:29Z   [info]Unpacking image
2022-03-05T03:48:30Z   [info]Preparing kernel init
2022-03-05T03:48:32Z   [info]Configuring firecracker
2022-03-05T03:48:32Z   [info]Starting virtual machine
2022-03-05T03:48:32Z   [info]Starting init (commit: 0c50bff)...
2022-03-05T03:48:32Z   [info]Preparing to run: `/app/bin/server` as nobody
2022-03-05T03:48:32Z   [info]2022/03/05 03:48:32 listening on [fdaa:0:512b:a7b:5adc:c91a:829e:2]:22 (DNS: [fdaa::3]:53)
2022-03-05T03:48:33Z   [info]Reaped child process with pid: 551, exit code: 0
2022-03-05T03:48:35Z   [info]Reaped child process with pid: 572 and signal: SIGUSR1, core dumped? false
--> v3 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v4 

--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort

Could you post your config/runtime.exs and fly.toml?

runtime.exs
everything is in prod.exs .it is commented bcoz if i uncomment this it throws and error config is not defined

#use 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.
#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
#    """
#database_url =
#  System.get_env("DATABASE_URL") ||
#    raise """
#    environment variable DATABASE_URL is missing.
#    For example: ecto://USER:PASS@HOST/DATABASE
#    """
#config :fchatapp, FchatappWeb.Endpoint,
#       url: [host: "#{app_name}.fly.dev", port: 80],
#       http: [
#         # Enable IPv6 and bind on all interfaces.
#         # Set it to  {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
#         # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
#         # for details about using IPv6 vs IPv4 and loopback vs public addresses.
#         ip: {0, 0, 0, 0, 0, 0, 0, 0},
#         port: String.to_integer(System.get_env("PORT") || "4000")
#       ],
#       secret_key_base: secret_key_base
#
#config :fchatapp, Fchatapp.Repo,
#       # ssl: true,
#       url: database_url,
#       socket_options: [:inet6],
#       pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

#config :fchatapp, FchatappWeb.Endpoint,
#       url: [host: "example.com", port: 80],
#       cache_static_manifest: "priv/static/cache_manifest.json"

# 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.

fly.toml

# fly.toml file generated for chatapp on 2022-03-05T02:11:15Z

app = "chatapp"

kill_signal = "SIGTERM"
kill_timeout = 5
processes = []

[deploy]
  release_command = "/app/bin/migrate"

[env]
  PHX_HOST = "chatapp.fly.dev"
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

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: "example.com", port: 80],
#  cache_static_manifest: "priv/static/cache_manifest.json"

database_url =
  System.get_env("DATABASE_URL") ||
    "placed URL maually"
config :fchatapp, Fchatapp.Repo,
       # ssl: true,
       url: database_url,
       socket_options: [:inet6],
       pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

secret_key_base =
  System.get_env("SECRET_KEY_BASE") ||
    "placed key manually"

app_name =
  System.get_env("FLY_APP_NAME") ||
    "chatapp"
config :fchatapp, FchatappWeb.Endpoint,
       url: [host: "#{app_name}.fly.dev", port: 80],
       http: [
         # Enable IPv6 and bind on all interfaces.
         # Set it to  {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
         # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
         # for details about using IPv6 vs IPv4 and loopback vs public addresses.
         ip: {0, 0, 0, 0, 0, 0, 0, 0},
         port: String.to_integer(System.get_env("PORT") || "8080")
       ],
       secret_key_base: secret_key_base
#       cache_static_manifest: "priv/static/cache_manifest.json"


# 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"

have a look please

I think runtime.exs throws an error that Config is not defined because you have use Config at the top of the file. Try using use Mix.Config in runtime.exs since that matches what you have in prod.exs.

Take a look at hello_elixir to see an example of how a Phoenix app can be setup for Fly.

I gave my shot at updating your runtime.exs:

use Mix.Config

# config/runtime.exs is executed for all environments, including
# during releases. It is executed after compilation and before the
# system starts, so it is typically used to load production configuration
# and secrets from environment variables or elsewhere. Do not define
# any compile-time configuration in here, as it won't be applied.
# The block below contains prod specific runtime configuration.
if config_env() == :prod do
  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,
    # ssl: true,
    # IMPORTANT: Or it won't find the DB server
    socket_options: [:inet6],
    url: database_url,
    pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

  # The secret key base is used to sign/encrypt cookies and other secrets.
  # A default value is used in config/dev.exs and config/test.exs but you
  # want to use a different value for prod and you most likely don't want
  # to check this value into version control, so we use an environment
  # variable instead.
  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"

  config :fchatapp, FchatappWeb.Endpoint,
    url: [host: "#{app_name}.fly.dev", port: 80],
    http: [
      # Enable IPv6 and bind on all interfaces.
      # Set it to  {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
      # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
      # for details about using IPv6 vs IPv4 and loopback vs public addresses.
      ip: {0, 0, 0, 0, 0, 0, 0, 0},
      port: String.to_integer(System.get_env("PORT") || "8080")
    ],
    secret_key_base: secret_key_base

  # ## Using releases
  #
  # If you are doing OTP releases, you need to instruct Phoenix
  # to start each relevant endpoint:
  #
  config :fchatapp, FchatappWeb.Endpoint, server: true
end

if config_env() == :dev do
  database_url = System.get_env("DATABASE_URL")

  if database_url != nil do
    config :fchatapp, Fchatapp.Repo,
      url: database_url,
      socket_options: [:inet6]
  end
end

By the way i had already tried it but just verify here is the second try
runtime.exs

use Mix.Config

# config/runtime.exs is executed for all environments, including
# during releases. It is executed after compilation and before the
# system starts, so it is typically used to load production configuration
# and secrets from environment variables or elsewhere. Do not define
# any compile-time configuration in here, as it won't be applied.
# The block below contains prod specific runtime configuration.
if config_env() == :prod do
  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,
         # ssl: true,
         # IMPORTANT: Or it won't find the DB server
         socket_options: [:inet6],
         url: database_url,
         pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")

  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"

  config :fchatapp, FchatappWeb.Endpoint,
         url: [host: "#{app_name}.fly.dev", port: 80],
         http: [
           # Enable IPv6 and bind on all interfaces.
           # Set it to  {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
           # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
           # for details about using IPv6 vs IPv4 and loopback vs public addresses.
           ip: {0, 0, 0, 0, 0, 0, 0, 0},
           port: String.to_integer(System.get_env("PORT") || "8080")
         ],
         secret_key_base: secret_key_base

  # ## Using releases
  #
  # If you are doing OTP releases, you need to instruct Phoenix
  # to start each relevant endpoint:
  #
  config :fchatapp, FchatappWeb.Endpoint, server: true

  # ## Configuring the mailer
  #
  # In production you need to configure the mailer to use a different adapter.
  # Also, you may need to configure the Swoosh API client of your choice if you
  # are not using SMTP. Here is an example of the configuration:
  #
  #     config :hello_elixir, HelloElixir.Mailer,
  #       adapter: Swoosh.Adapters.Mailgun,
  #       api_key: System.get_env("MAILGUN_API_KEY"),
  #       domain: System.get_env("MAILGUN_DOMAIN")
  #
  # For this example you need include a HTTP client required by Swoosh API client.
  # Swoosh supports Hackney and Finch out of the box:
  #
  #     config :swoosh, :api_client, Swoosh.ApiClient.Hackney
  #
  # See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.

 end

after I run command fly deploy here is result

--> Pushing image done
image: registry.fly.io/chatapp:deployment-1646520807
image size: 123 MB
         Starting instance
         Pulling container image
         Preparing kernel init
         Starting virtual machine
         Preparing to run: `/app/bin/migrate` as nobody
         ERROR! Config provider Config.Reader failed with:
             (elixir 1.12.3) src/elixir_expand.erl:87: :elixir_expand.expand/2
             (elixir 1.12.3) src/elixir_expand.erl:40: :elixir_expand.expand/2
             /app/releases/0.1.0/runtime.exs:1: (file)
         {"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.CompileError',description=><<"module Mix.Config is not loaded and could not be fError release command failed, deployment aborted
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

here are the logs

2022-03-05T22:54:21Z app[f49d31a4] lhr [info]Starting init (commit: 0c50bff)...
2022-03-05T22:54:21Z app[f49d31a4] lhr [info]Preparing to run: `/app/bin/migrate` as nobody
2022-03-05T22:54:21Z app[f49d31a4] lhr [info]2022/03/05 22:54:21 listening on [fdaa:0:512b:a7b:276d:f49d:31a4:2]:22 (DNS: [fdaa::3]:53)
2022-03-05T22:54:22Z app[f49d31a4] lhr [info]ERROR! Config provider Config.Reader failed with:
2022-03-05T22:54:22Z app[f49d31a4] lhr [info]** (CompileError) /app/releases/0.1.0/runtime.exs:1: module Mix.Config is not loaded and could not be found
2022-03-05T22:54:22Z app[f49d31a4] lhr [info]    (elixir 1.12.3) src/elixir_expand.erl:87: :elixir_expand.expand/2
2022-03-05T22:54:22Z app[f49d31a4] lhr [info]    (elixir 1.12.3) src/elixir_expand.erl:538: :elixir_expand.expand_block/4
2022-03-05T22:54:22Z app[f49d31a4] lhr [info]    (elixir 1.12.3) src/elixir_expand.erl:40: :elixir_expand.expand/2
2022-03-05T22:54:22Z app[f49d31a4] lhr [info]    (elixir 1.12.3) expanding macro: Kernel.use/1
2022-03-05T22:54:22Z app[f49d31a4] lhr [info]    /app/releases/0.1.0/runtime.exs:1: (file)
2022-03-05T22:54:22Z app[f49d31a4] lhr [info]{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.CompileError',description=><<"module Mix.Config is not loaded and could not be found">>,file=><<"/app/releases/0.1.0/runtime.exs">>,line=>1},[{elixir_expand,expand,2,[{file,"src/elixir_expand.erl"},{line,87}]},{elixir_expand,expand_block,4,[{file,"src/elixir_expand.erl"},{line,538}]},{elixir_expand,expand,2,[{file,"src/elixir_expand.erl"},{line,40}]},{'Elixir.Kernel',use,1,[{file,"expanding macro"}]},{elixir_compiler_0,'__FILE__',1,[{file,"/app/releases/0.1.0/runtime.exs"},{line,1}]}]}}
2022-03-05T22:54:22Z app[f49d31a4] lhr [info]init terminating in do_boot ({,[{elixir_expand,expand,2,[{_},{_}]},{elixir_expand,expand_block,4,[{_},{_}]},{elixir_expand,expand,2,[{_},{_}]},{Elixir.Kernel,use,1,[{_}]},{elixir_compiler_0,__FILE__,1
2022-03-05T22:54:22Z app[f49d31a4] lhr [info]Crash dump is being written to: erl_crash.dump...done
2022-03-05T22:54:23Z app[f49d31a4] lhr [info]Main child exited normally with code: 1
2022-03-05T22:54:23Z app[f49d31a4] lhr [info]Reaped child process with pid: 564 and signal: SIGUSR1, core dumped? false
2022-03-05T22:54:23Z app[f49d31a4] lhr [info]Starting clean up.


please have a look

I noticed your error message talks about not “finding” Mix.Config and also the posted source you have shows you using use Mix.Config, but you’re using elixir 1.12.3 and use Mix.config was deprecated for import Config in Elixir 1.9 Elixir v1.9 released - The Elixir programming language

1 Like

if I use Config then it says config/3 is not defined for the same code?

use Config and results

]** (CompileError) /app/releases/0.1.0/runtime.exs:17: undefined function config/3
2022-03-06T00:19:24Z app[71bb8a29] lhr [info]    (elixir 1.12.3) src/elixir_expand.erl:538: :elixir_expand.expand_block/4
2022-03-06T00:19:24Z app[71bb8a29] lhr [info]    (elixir 1.12.3) src/elixir_expand.erl:40: :elixir_expand.expand/2
2022-03-06T00:19:24Z app[71bb8a29] lhr [info]    (elixir 1.12.3) src/elixir.erl:334: :elixir.quoted_to_erl/3
2022-03-06T00:19:24Z app[71bb8a29] lhr [info]    (elixir 1.12.3) src/elixir.erl:251: :elixir.eval_forms/3
2022-03-06T00:19:24Z app[71bb8a29] lhr [info]    (elixir 1.12.3) lib/code.ex:656: Code.eval_string_with_error_handling/3
2022-03-06T00:19:24Z app[71bb8a29] lhr [info]    (elixir 1.12.3) lib/config.ex:258: Config.__eval__!/3
2022-03-06T00:19:24Z app[71bb8a29] lhr [info]    (elixir 1.12.3) lib/config/reader.ex:86: Config.Reader.read!/2
2022-03-06T00:19:24Z app[71bb8a29] lhr [info]{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.CompileError',description=><<"undefined function config/3">>,file=><<"/app/releases/0.1.0/runtime.exs">>,line=>17},[{elixir_expand,expand_block,4,[{file,"src/elixir_expand.erl"},{line,538}]},{elixir_expand,expand,2,[{file,"src/elixir_expand.erl"},{line,40}]},{elixir,quoted_to_erl,3,[{file,"src/elixir.erl"},{line,334}]},{elixir,eval_forms,3,[{file,"src/elixir.erl"},{line,251}]},{'Elixir.Code',eval_string_with_error_handling,3,[{file,"lib/code.ex"},{line,656}]},{'Elixir.Config','__eval__!',3,[{file,"lib/config.ex"},{line,258}]},{'Elixir.Config.Reader','read!',2,[{file,"lib/config/reader.ex"},{line,86}]}]}}
2022-03-06T00:19:24Z app[71bb8a29] lhr [info]init terminating in do_boot ({,[{elixir_expand,expand_block,4,[{_},{_}]},{elixir_expand,expand,2,[{_},{_}]},{elixir,quoted_to_erl,3,[{_},{_}]},{elixir,eval_forms,3,[{_},{_}]},{Elixir.Code,eval_string_
2022-03-06T00:19:24Z app[71bb8a29] lhr [info]Crash dump is being written to: erl_crash.dump...done
2022-03-06T00:19:25Z app[71bb8a29] lhr [info]Star child exited normally with code: 1
2022-03-06T00:19:25Z app[71bb8a29] lhr [info]Starting clean up.


Yes, that’s why I said import Config.

1 Like

Thanks alot my friend its deployed