bitwalker / distillery

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

released app crash on run #669

Closed xxhenglyxx closed 5 years ago

xxhenglyxx commented 5 years ago

Steps to reproduce

path to run bin/app_server/foreground

Verbose Logs

Paste the output of the release command you ran with the --verbose flag below in the summary tags (this helps keep the issue easy to navigate):

``` ==> Loading configuration.. ==> Assembling release.. ==> Building release app_server:0.16.6 using environment prod ==> Discovered applications: > phoenix_ecto-4.0.0 | | from: _build/prod/lib/phoenix_ecto | applications: | :kernel | :stdlib | :elixir | :logger | :ecto | :plug | includes: none |_____ > plug_crypto-1.0.0 | | from: _build/prod/lib/plug_crypto | applications: | :kernel | :stdlib | :elixir | :crypto | includes: none |_____ > kernel-6.2 | | from: /usr/lib/erlang/lib/kernel-6.2 | applications: none | includes: none |_____ > ranch-1.7.1 | | from: _build/prod/lib/ranch | applications: | :kernel | :stdlib | :ssl | includes: none |_____ > cowlib-2.7.3 | | from: _build/prod/lib/cowlib | applications: | :kernel | :stdlib | :crypto | includes: none |_____ > cowboy-2.6.3 | | from: _build/prod/lib/cowboy | applications: | :kernel | :stdlib | :crypto | :cowlib | :ranch | includes: none |_____ > plug_cowboy-2.0.2 | | from: _build/prod/lib/plug_cowboy | applications: | :kernel | :stdlib | :elixir | :logger | :cowboy | :plug | includes: none |_____ > artificery-0.4.2 | | from: _build/prod/lib/artificery | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > distillery-2.0.14 | | from: _build/prod/lib/distillery | applications: | :kernel | :stdlib | :elixir | :runtime_tools | :artificery | includes: none |_____ > db_connection-2.0.6 | | from: _build/prod/lib/db_connection | applications: | :kernel | :stdlib | :elixir | :logger | :connection | includes: none |_____ > connection-1.0.4 | | from: _build/prod/lib/connection | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > postgrex-0.14.3 | | from: _build/prod/lib/postgrex | applications: | :kernel | :stdlib | :elixir | :logger | :crypto | :connection | :decimal | :db_connection | includes: none |_____ > eex-1.8.1 | | from: /usr/lib/elixir/bin/../lib/eex | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > phoenix-1.4.6 | | from: _build/prod/lib/phoenix | applications: | :kernel | :stdlib | :elixir | :logger | :eex | :crypto | :phoenix_pubsub | :plug | includes: none |_____ > mime-1.3.1 | | from: _build/prod/lib/mime | applications: | :kernel | :stdlib | :elixir | :logger | includes: none |_____ > plug-1.8.0 | | from: _build/prod/lib/plug | applications: | :kernel | :stdlib | :elixir | :logger | :mime | :plug_crypto | includes: none |_____ > absinthe_plug-1.4.7 | | from: _build/prod/lib/absinthe_plug | applications: | :kernel | :stdlib | :elixir | :logger | :plug | :absinthe | includes: none |_____ > nanoid-2.0.1 | | from: _build/prod/lib/nanoid | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > poolboy-1.5.2 | | from: _build/prod/lib/poolboy | applications: | :kernel | :stdlib | includes: none |_____ > phoenix_pubsub_redis-2.1.7 | | from: _build/prod/lib/phoenix_pubsub_redis | applications: | :kernel | :stdlib | :elixir | :logger | :poolboy | :redix | :phoenix_pubsub | includes: none |_____ > runtime_tools-1.13.1 | | from: /usr/lib/erlang/lib/runtime_tools-1.13.1 | applications: | :kernel | :stdlib | includes: none |_____ > stdlib-3.7.1 | | from: /usr/lib/erlang/lib/stdlib-3.7.1 | applications: | :kernel | includes: none |_____ > phoenix_pubsub-1.1.2 | | from: _build/prod/lib/phoenix_pubsub | applications: | :kernel | :stdlib | :elixir | :logger | :crypto | includes: none |_____ > decimal-1.7.0 | | from: _build/prod/lib/decimal | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > ecto-3.1.4 | | from: _build/prod/lib/ecto | applications: | :kernel | :stdlib | :elixir | :logger | :crypto | :decimal | includes: none |_____ > crypto-4.4 | | from: /usr/lib/erlang/lib/crypto-4.4 | applications: | :kernel | :stdlib | includes: none |_____ > absinthe_ecto-0.1.3 | | from: _build/prod/lib/absinthe_ecto | applications: | :kernel | :stdlib | :elixir | :logger | :absinthe | :ecto | includes: none |_____ > httpoison-1.5.1 | | from: _build/prod/lib/httpoison | applications: | :kernel | :stdlib | :elixir | :hackney | includes: none |_____ > xmerl-1.3.19 | | from: /usr/lib/erlang/lib/xmerl-1.3.19 | applications: | :kernel | :stdlib | includes: none |_____ > sweet_xml-0.6.6 | | from: _build/prod/lib/sweet_xml | applications: | :kernel | :stdlib | :elixir | :xmerl | includes: none |_____ > phoenix_html-2.13.2 | | from: _build/prod/lib/phoenix_html | applications: | :kernel | :stdlib | :elixir | :logger | :plug | includes: none |_____ > certifi-2.5.1 | | from: _build/prod/lib/certifi | applications: | :kernel | :stdlib | includes: none |_____ > metrics-1.0.1 | | from: _build/prod/lib/metrics | applications: | :kernel | :stdlib | includes: none |_____ > ssl_verify_fun-1.1.4 | | from: _build/prod/lib/ssl_verify_fun | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > mimerl-1.2.0 | | from: _build/prod/lib/mimerl | applications: | :kernel | :stdlib | includes: none |_____ > unicode_util_compat-0.4.1 | | from: _build/prod/lib/unicode_util_compat | applications: | :kernel | :stdlib | includes: none |_____ > idna-6.0.0 | | from: _build/prod/lib/idna | applications: | :kernel | :stdlib | :unicode_util_compat | includes: none |_____ > ssl-9.1.2 | | from: /usr/lib/erlang/lib/ssl-9.1.2 | applications: | :crypto | :public_key | :kernel | :stdlib | includes: none |_____ > public_key-1.6.4 | | from: /usr/lib/erlang/lib/public_key-1.6.4 | applications: | :asn1 | :crypto | :kernel | :stdlib | includes: none |_____ > asn1-5.0.8 | | from: /usr/lib/erlang/lib/asn1-5.0.8 | applications: | :kernel | :stdlib | includes: none |_____ > hackney-1.15.1 | | from: _build/prod/lib/hackney | applications: | :kernel | :stdlib | :crypto | :asn1 | :public_key | :ssl | :idna | :mimerl | :certifi | :ssl_verify_fun | :metrics | includes: none |_____ > ex_aws-2.1.1 | | from: _build/prod/lib/ex_aws | applications: | :kernel | :stdlib | :elixir | :logger | :crypto | includes: none |_____ > gen_smtp-0.12.0 | | from: _build/prod/lib/gen_smtp | applications: | :kernel | :stdlib | :crypto | :asn1 | :public_key | :ssl | includes: none |_____ > bamboo_smtp-1.6.0 | | from: _build/prod/lib/bamboo_smtp | applications: | :kernel | :stdlib | :elixir | :gen_smtp | :logger | :bamboo | includes: none |_____ > bamboo-1.2.0 | | from: _build/prod/lib/bamboo | applications: | :kernel | :stdlib | :elixir | :logger | :hackney | includes: none |_____ > cors_plug-2.0.0 | | from: _build/prod/lib/cors_plug | applications: | :kernel | :stdlib | :elixir | :logger | includes: none |_____ > base64url-0.0.1 | | from: _build/prod/lib/base64url | applications: | :kernel | :stdlib | includes: none |_____ > jose-1.9.0 | | from: _build/prod/lib/jose | applications: | :kernel | :stdlib | :elixir | :crypto | :asn1 | :public_key | :base64url | includes: none |_____ > guardian-1.2.1 | | from: _build/prod/lib/guardian | applications: | :kernel | :stdlib | :elixir | :crypto | :logger | :jose | includes: none |_____ > absinthe_phoenix-1.4.4 | | from: _build/prod/lib/absinthe_phoenix | applications: | :kernel | :stdlib | :elixir | :logger | :decimal | :absinthe | :phoenix_pubsub | :phoenix | :absinthe_plug | includes: none |_____ > telemetry-0.4.0 | | from: _build/prod/lib/telemetry | applications: | :kernel | :stdlib | includes: none |_____ > ecto_sql-3.1.3 | | from: _build/prod/lib/ecto_sql | applications: | :kernel | :stdlib | :elixir | :logger | :telemetry | :db_connection | :ecto | includes: none |_____ > absinthe-1.4.16 | | from: _build/prod/lib/absinthe | applications: | :kernel | :stdlib | :elixir | :logger | includes: none |_____ > dataloader-1.0.6 | | from: _build/prod/lib/dataloader | applications: | :kernel | :stdlib | :elixir | :logger | includes: none |_____ > ex_aws_s3-2.0.2 | | from: _build/prod/lib/ex_aws_s3 | applications: | :kernel | :stdlib | :elixir | :logger | :ex_aws | includes: none |_____ > comeonin-5.1.2 | | from: _build/prod/lib/comeonin | applications: | :kernel | :stdlib | :elixir | :logger | includes: none |_____ > argon2_elixir-2.0.5 | | from: _build/prod/lib/argon2_elixir | applications: | :kernel | :stdlib | :elixir | :logger | :crypto | :comeonin | includes: none |_____ > jason-1.1.2 | | from: _build/prod/lib/jason | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > gettext-0.16.1 | | from: _build/prod/lib/gettext | applications: | :kernel | :stdlib | :elixir | :logger | includes: none |_____ > redix-0.9.3 | | from: _build/prod/lib/redix | applications: | :kernel | :stdlib | :elixir | :logger | includes: none |_____ > elixir_uuid-1.2.0 | | from: _build/prod/lib/elixir_uuid | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > logger-1.8.1 | | from: /usr/lib/elixir/bin/../lib/logger | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > app_server-0.16.6 | | from: _build/prod/lib/app_server | applications: | :kernel | :stdlib | :elixir | :logger | :runtime_tools | :elixir_uuid | :redix | :gettext | :jason | :argon2_elixir | :hackney | :sweet_xml | :ex_aws | :ex_aws_s3 | :httpoison | :dataloader | :absinthe | :absinthe_ecto | :phoenix_pubsub | :phoenix_pubsub_redis | :nanoid | :postgrex | :ecto_sql | :distillery | :phoenix_html | :plug_cowboy | :phoenix | :absinthe_plug | :absinthe_phoenix | :guardian | :cors_plug | :bamboo | :bamboo_smtp | :phoenix_ecto | includes: none |_____ > compiler-7.3.1 | | from: /usr/lib/erlang/lib/compiler-7.3.1 | applications: | :kernel | :stdlib | includes: none |_____ > sasl-3.3 | | from: /usr/lib/erlang/lib/sasl-3.3 | applications: | :kernel | :stdlib | includes: none |_____ > iex-1.8.1 | | from: /usr/lib/elixir/bin/../lib/iex | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > mix-1.8.1 | | from: /usr/lib/elixir/bin/../lib/mix | applications: | :kernel | :stdlib | :elixir | includes: none |_____ > elixir-1.8.1 | | from: /usr/lib/elixir/bin/../lib/elixir | applications: | :kernel | :stdlib | :compiler | includes: none |_____ ==> Running validation checks.. > Mix.Releases.Checks.Erts * PASS > Mix.Releases.Checks.Cookie * PASS > Mix.Releases.Checks.LoadedOrphanedApps * PASS ==> Generated overlay vars: release_name=:app_server release_version="0.16.6" is_upgrade=false upgrade_from=:latest dev_mode=false include_erts=true include_src=false include_system_libs=true erl_opts="" run_erl_env="" erts_vsn="10.2.4" output_dir="_build/prod/rel/app_server" ==> Copying applications to _build/prod/rel/app_server ==> Generating start_erl.data ==> Generating vm.args from rel/vm.args ==> Generating sys.config from config/config.exs ==> Including ERTS 10.2.4 from /usr/lib/erlang/erts-10.2.4 ==> Generating boot scripts ==> Generating RELEASES ==> Applying overlays ==> Applying mkdir overlay dst: releases/0.16.6/hooks ==> Applying mkdir overlay dst: releases/0.16.6/hooks/pre_configure.d ==> Applying mkdir overlay dst: releases/0.16.6/hooks/post_configure.d ==> Applying mkdir overlay dst: releases/0.16.6/hooks/pre_start.d ==> Applying mkdir overlay dst: releases/0.16.6/hooks/post_start.d ==> Applying mkdir overlay dst: releases/0.16.6/hooks/pre_stop.d ==> Applying mkdir overlay dst: releases/0.16.6/hooks/post_stop.d ==> Applying mkdir overlay dst: releases/0.16.6/hooks/pre_upgrade.d ==> Applying mkdir overlay dst: releases/0.16.6/hooks/post_upgrade.d ==> Applying copy overlay src: _build/prod/lib/distillery/priv/libexec dst: releases/0.16.6/libexec ==> Applying mkdir overlay dst: releases/0.16.6/commands ==> Applying copy overlay src: rel/runtime_config.exs dst: etc/runtime_config.exs ==> Packaging release.. ==> Archiving app_server-0.16.6 ==> Writing archive to /opt/app/_build/prod/rel/app_server/releases/0.16.6/app_server.tar.gz ==> Updating archive.. ==> Including system libs from current Erlang installation ==> Saving archive.. ==> Archive saved! Release successfully built! To start the release you have built, you can use one of the following tasks: # start a shell, like 'iex -S mix' > _build/prod/rel/app_server/bin/app_server console # start in the foreground, like 'mix run --no-halt' > _build/prod/rel/app_server/bin/app_server foreground # start in the background, must be stopped with the 'stop' command > _build/prod/rel/app_server/bin/app_server start If you started a release elsewhere, and wish to connect to it: # connects a local shell to the running node > _build/prod/rel/app_server/bin/app_server remote_console # connects directly to the running node's console > _build/prod/rel/app_server/bin/app_server attach For a complete listing of commands and their use: > _build/prod/rel/app_server/bin/app_server help ```

Description of issue

init terminating in do_boot ({,[{erlang,binary_to_integer,
,[]},{erl_eval,do_apply,6,[{_},{_}]},{erl_eval,expr,5,[{_},{_}]},{erl_eval,exprs,5,[{_},{_}]},{elixir,eval_forms,4,[{_},{_}]},{Elixir.Code,ev

Crash dump is being written to: erl_crash.dump...done
=INFO REPORT==== 20-May-2019::13:42:47.674549 ===
    application: mix
    exited: stopped
    type: temporary
argument error
    :erlang.binary_to_integer(10)
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
    (stdlib) erl_eval.erl:449: :erl_eval.expr/5
    (stdlib) erl_eval.erl:126: :erl_eval.exprs/5
    (elixir) src/elixir.erl:258: :elixir.eval_forms/4
    (elixir) lib/code.ex:232: Code.eval_string/3
    (mix) lib/mix/config.ex:220: Mix.Config.eval!/2
    (distillery) lib/mix/lib/releases/config/providers/elixir.ex:80: Mix.Releases.Config.Providers.Elixir.eval!/2

{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.ArgumentError',message=><<"argument error">>},[{erlang,binary_to_integer,"\n",[]},{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,680}]},{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,449}]},{erl_eval,exprs,5,[{file,"erl_eval.erl"},{line,126}]},{elixir,eval_forms,4,[{file,"src/elixir.erl"},{line,258}]},{'Elixir.Code',eval_string,3,[{file,"lib/code.ex"},{line,232}]},{'Elixir.Mix.Config','eval!',2,[{file,"lib/mix/config.ex"},{line,220}]},{'Elixir.Mix.Releases.Config.Providers.Elixir','eval!',2,[{file,"lib/mix/lib/releases/config/providers/elixir.ex"},{line,80}]}]}}
Unable to configure release!

use Mix.Releases.Config, default_release: :default, default_environment: Mix.env()

environment :dev do set dev_mode: true set includeerts: false set cookie: :"l5IbBfyF]$21)C)uk?K88<cQj(UpeFD(*9FSotIg!}&{S0HVE,q.te59Q}X%Z" end

environment :prod do set include_erts: true set includesrc: false set cookie: :"IP)x/}2r:c@uJpHBIKm4%=N|t3BAgyP^d2)wv0vw!mhNdES3k.Bl,i&Io<N/sXg" set vm_args: "rel/vm.args"

set config_providers: [ {Mix.Releases.Config.Providers.Elixir, ["${RELEASE_ROOT_DIR}/etc/runtime_config.exs"]} ]

set overlays: [ {:copy, "rel/runtime_config.exs", "etc/runtime_config.exs"} ] end

release :app_server do set version: current_version(:app_server) set applications: [ :runtime_tools ] end

rel/runtime_config.exs

use Mix.Config

db_pool = String.to_integer(System.get_env("DB_POOL") || 10) smtp_port = String.to_integer(System.get_env("SMTP_PORT") || 587) server_port = String.to_integer(System.get_env("SERVER_PORT") || 5000) redis_pool = String.to_integer(System.get_env("REDIS_POOL_SIZE") || 5)

config :app_server, AppServer.Mailer, server: System.get_env("SMTP_SERVER"), hostname: System.get_env("SMTP_HOST"), port: smtp_port, username: System.get_env("SMTP_USER"), password: System.get_env("SMTP_PASSWORD")

config :app_server, AppServer.Repo, username: System.get_env("DB_USER"), password: System.get_env("DB_PASSWORD"), database: System.get_env("DB_NAME"), hostname: System.get_env("DB_HOST"), pool_size: db_pool

config :app_server, AppServerWeb.Endpoint, secret_key_base: System.get_env("SECRET_KEY_BASE"), url: [host: System.get_env("SERVER_HOST"), port: server_port], http: [:inet6, port: server_port], pubsub: [ adapter: Phoenix.PubSub.Redis, node_name: System.get_env("REDIS_NODE"), host: System.get_env("REDIS_HOST"), name: AppServer.PubSub, pool_size: redis_pool ]

config :app_server, AppServer.Guardian, issuer: System.get_env("JWT_TOKEN_ISSUER"), secret_key: System.get_env("JWT_SECRET_KEY")

config :ex_aws, debug_requests: false, access_key_id: System.get_env("AWS_API_KEY"), secret_access_key: System.get_env("AWS_API_SECRET"), s3: [ scheme: "https://", host: System.get_env("AWS_BUCKET_NAME") <> ".s3.amazonaws.com", region: System.get_env("AWS_BUCKET_REGION") ]

config :app_server, :aws_bucket_name, System.get_env("AWS_BUCKET_NAME")

config :app_server, :smtp_user, System.get_env("SMTP_USER")

config :app_server, :redis_cache_host, System.get_env("REDIS_CACHE_HOST")

config :app_server, :cors_origin, System.get_env("CORS_ORIGIN")

config :app_server, :nexmo_api_key, System.get_env("NEXMO_API_KEY") config :app_server, :nexmo_api_secret, System.get_env("NEXMO_API_SECRET")


- Is there documentation that says one thing, but Distillery does
  another? If so, please link the doc here so it can be updated if
  it's a documentation issue, or so that the fix can be based around
  what's documented. -> I think no, the release works before but not now.
- If this is a runtime configuration issue, please also provide your config file 
  (with any sensitive information stripped of course). This is almost
  always necessary to understand why some configuration may not be working. -> Already provided along with `rel/config.exs`

The error are both the same inside docker and on my mac machine, they both release success but error when running it.
xxhenglyxx commented 5 years ago

Sorry for this silly issue lol, the problem was actually about the System.get_env("DB_POOL"), which my environment variable name was DB_POOL_SIZE=10, after changing it back to DB_POOL, it works as expected now.

redpublic commented 4 years ago

Sorry for this silly issue lol, the problem was actually about the System.get_env("DB_POOL"), which my environment variable name was DB_POOL_SIZE=10, after changing it back to DB_POOL, it works as expected now.

@xxhenglyxx How did you get the incorrect line in your runtime_config.exs? Sometimes it becomes quite a task as there is no runtime_config line number in stack_trace