bitwalker / distillery

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

Create release build but application server is not running #433

Closed punitcse closed 6 years ago

punitcse commented 6 years ago

Steps to reproduce

Create the build using command MIX_ENV=prod mix release --env=prod --verbose. It successfully creates the build and I can able to run the console and ping. Even when I run the start command it successfully started but when I go to htttp://localhost:4000, server does not run.

Expected result

When I run PORT=4000 _build/prod/rel/trackbees/bin/trackbees start it should start the daemon and I can see the localhost:4000 running. I also could not able to see any log while checking with PORT=4000 _build/prod/rel/trackbees/bin/trackbees foreground command.

Verbose Logs

``` $ MIX_ENV=prod mix release --env=prod --verbose Generated trackbees app ==> Loading configuration.. ==> Assembling release.. ==> Building release trackbees:0.0.1 using environment prod ==> One or more direct or transitive dependencies are missing from :applications or :included_applications, they will not be included in the release: :jsx This can cause your application to fail at runtime. If you are sure that this is not an issue, you may ignore this warning. ==> Discovered applications: thumbnex-0.2.4 from: _build/prod/lib/thumbnex applications: :kernel :stdlib :elixir :logger includes: none xmerl-1.3.15 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/xmerl-1.3.15 applications: :kernel :stdlib includes: none sweet_xml-0.6.5 from: _build/prod/lib/sweet_xml applications: :kernel :stdlib :elixir :xmerl includes: none secure_random-0.5.1 from: _build/prod/lib/secure_random applications: :kernel :stdlib :elixir :logger :crypto includes: none rummage_ecto-1.1.0 from: _build/prod/lib/rummage_ecto applications: :kernel :stdlib :elixir :logger :ecto :postgrex includes: none phoenix_api_docs-0.1.0 from: _build/prod/lib/phoenix_api_docs applications: :kernel :stdlib :elixir :poison :plug includes: none mogrify-0.5.6 from: _build/prod/lib/mogrify applications: :kernel :stdlib :elixir :crypto :logger includes: none ffmpex-0.4.1 from: _build/prod/lib/ffmpex applications: :kernel :stdlib :elixir :logger includes: none exactor-2.2.4 from: _build/prod/lib/exactor applications: :kernel :stdlib :elixir :logger includes: none elixir_make-0.4.0 from: _build/prod/lib/elixir_make applications: :kernel :stdlib :elixir includes: none base64url-0.0.1 from: _build/prod/lib/base64url applications: :kernel :stdlib includes: none jose-1.8.3 from: _build/prod/lib/jose applications: :kernel :stdlib :elixir :crypto :asn1 :public_key :base64url includes: none guardian-0.14.2 from: _build/prod/lib/guardian applications: :kernel :stdlib :elixir :logger :poison :jose :uuid includes: none exgravatar-2.0.0 from: _build/prod/lib/exgravatar applications: :kernel :stdlib :elixir :crypto includes: none ex_aws_s3-2.0.0 from: _build/prod/lib/ex_aws_s3 applications: :kernel :stdlib :elixir :logger :ex_aws includes: none xain-0.6.0 from: _build/prod/lib/xain applications: :kernel :stdlib :elixir :logger includes: none ex_queb-1.0.0 from: _build/prod/lib/ex_queb applications: :kernel :stdlib :elixir :logger includes: none csvlixir-1.0.0 from: _build/prod/lib/csvlixir applications: :kernel :stdlib :elixir includes: none scrivener_ecto-1.3.0 from: _build/prod/lib/scrivener_ecto applications: :kernel :stdlib :elixir :scrivener :logger includes: none scrivener-2.4.0 from: _build/prod/lib/scrivener applications: :kernel :stdlib :elixir :logger includes: none ex_admin-0.9.0-dev from: _build/prod/lib/ex_admin applications: :kernel :stdlib :elixir :gettext :phoenix :ecto :inflex :scrivener :scrivener_ecto :csvlixir :logger :ex_queb :xain includes: none elixlsx-0.3.0 from: _build/prod/lib/elixlsx applications: :kernel :stdlib :elixir includes: none edeliver-1.4.6 from: _build/prod/lib/edeliver applications: :kernel :stdlib :elixir includes: none ecto_enum-1.0.1 from: _build/prod/lib/ecto_enum applications: :kernel :stdlib :elixir :logger :ecto includes: none cors_plug-1.2.1 from: _build/prod/lib/cors_plug applications: :kernel :stdlib :elixir :logger includes: none comeonin-3.0.2 from: _build/prod/lib/comeonin applications: :kernel :stdlib :elixir :crypto :logger includes: none canary-1.1.1 from: _build/prod/lib/canary applications: :kernel :stdlib :elixir :logger includes: none canada-1.0.1 from: _build/prod/lib/canada applications: :kernel :stdlib :elixir includes: none basic_auth-2.2.2 from: _build/prod/lib/basic_auth applications: :kernel :stdlib :elixir :logger :cowboy :plug includes: none gen_smtp-0.11.0 from: _build/prod/lib/gen_smtp applications: :kernel :stdlib :crypto :asn1 :public_key :ssl includes: none bamboo_smtp-1.3.0 from: _build/prod/lib/bamboo_smtp applications: :kernel :stdlib :elixir :gen_smtp :logger :bamboo includes: none oauth2-0.9.1 from: _build/prod/lib/oauth2 applications: :kernel :stdlib :elixir :logger :hackney includes: none ueberauth_google-0.7.0 from: _build/prod/lib/ueberauth_google applications: :kernel :stdlib :elixir :logger :oauth2 :ueberauth includes: none ueberauth-0.4.0 from: _build/prod/lib/ueberauth applications: :kernel :stdlib :elixir :logger includes: none ueberauth_identity-0.2.3 from: _build/prod/lib/ueberauth_identity applications: :kernel :stdlib :elixir :logger :ueberauth includes: none ex_aws-2.0.2 from: _build/prod/lib/ex_aws applications: :kernel :stdlib :elixir :logger :crypto includes: none inets-6.4.4 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/inets-6.4.4 applications: :kernel :stdlib includes: none websocket_client-1.2.4 from: _build/prod/lib/websocket_client applications: :ssl :crypto :inets includes: none httpoison-0.13.0 from: _build/prod/lib/httpoison applications: :kernel :stdlib :elixir :hackney includes: none slack-0.12.0 from: _build/prod/lib/slack applications: :kernel :stdlib :elixir :logger :httpoison :hackney :crypto :websocket_client includes: none calendar-0.17.3 from: _build/prod/lib/calendar applications: :kernel :stdlib :elixir :logger :tzdata includes: none quantum-1.8.1 from: _build/prod/lib/quantum applications: :kernel :stdlib :elixir :calendar includes: none sentry-5.0.1 from: _build/prod/lib/sentry applications: :kernel :stdlib :elixir :hackney :uuid :poison :logger includes: none inflex-1.7.0 from: _build/prod/lib/inflex applications: :kernel :stdlib :elixir includes: none timex_ecto-3.1.1 from: _build/prod/lib/timex_ecto applications: :kernel :stdlib :elixir :logger :ecto :timex includes: none combine-0.9.6 from: _build/prod/lib/combine applications: :kernel :stdlib :elixir includes: none tzdata-0.5.12 from: _build/prod/lib/tzdata applications: :kernel :stdlib :elixir :hackney :logger includes: none timex-3.1.24 from: _build/prod/lib/timex applications: :kernel :stdlib :elixir :logger :tzdata :gettext :combine includes: none metrics-1.0.1 from: _build/prod/lib/metrics applications: :kernel :stdlib includes: none ssl_verify_fun-1.1.1 from: _build/prod/lib/ssl_verify_fun applications: :kernel :stdlib :ssl includes: none certifi-1.2.1 from: _build/prod/lib/certifi applications: :kernel :stdlib includes: none mimerl-1.0.2 from: _build/prod/lib/mimerl applications: :kernel :stdlib includes: none unicode_util_compat-0.2.0 from: _build/prod/lib/unicode_util_compat applications: :kernel :stdlib includes: none idna-5.0.2 from: _build/prod/lib/idna applications: :kernel :stdlib :unicode_util_compat includes: none hackney-1.8.6 from: _build/prod/lib/hackney applications: :kernel :stdlib :crypto :asn1 :public_key :ssl :idna :mimerl :certifi :ssl_verify_fun :metrics includes: none bamboo-0.8.0 from: _build/prod/lib/bamboo applications: :kernel :stdlib :elixir :logger :hackney :poison includes: none db_connection-1.1.3 from: _build/prod/lib/db_connection applications: :kernel :stdlib :elixir :logger :connection includes: none postgrex-0.13.5 from: _build/prod/lib/postgrex applications: :kernel :stdlib :elixir :logger :db_connection :decimal :crypto includes: none phoenix_pubsub-1.0.1 from: _build/prod/lib/phoenix_pubsub applications: :kernel :stdlib :elixir :logger :crypto includes: none phoenix_html-2.9.3 from: _build/prod/lib/phoenix_html applications: :kernel :stdlib :elixir :logger :plug includes: none poolboy-1.5.1 from: _build/prod/lib/poolboy applications: :kernel :stdlib includes: none decimal-1.5.0 from: _build/prod/lib/decimal applications: :kernel :stdlib :elixir includes: none ecto-2.1.6 from: _build/prod/lib/ecto applications: :kernel :stdlib :elixir :logger :decimal :poolboy includes: none phoenix_ecto-3.2.3 from: _build/prod/lib/phoenix_ecto applications: :kernel :stdlib :elixir :logger :ecto :plug includes: none eex-1.6.5 from: /Users/punitjain/.asdf/installs/elixir/1.6.5/bin/../lib/eex applications: :kernel :stdlib :elixir includes: none poison-2.2.0 from: _build/prod/lib/poison applications: :kernel :stdlib :elixir includes: none mime-1.1.0 from: _build/prod/lib/mime applications: :kernel :stdlib :elixir includes: none plug-1.3.5 from: _build/prod/lib/plug applications: :kernel :stdlib :elixir :crypto :logger :mime includes: none phoenix-1.2.3 from: _build/prod/lib/phoenix applications: :kernel :stdlib :elixir :plug :poison :logger :eex includes: none gettext-0.13.1 from: _build/prod/lib/gettext applications: :kernel :stdlib :elixir :logger includes: none uuid-1.1.7 from: _build/prod/lib/uuid applications: :kernel :stdlib :elixir includes: none connection-1.0.4 from: _build/prod/lib/connection applications: :kernel :stdlib :elixir includes: none redix-0.6.1 from: _build/prod/lib/redix applications: :kernel :stdlib :elixir :logger :connection includes: none exq-0.9.0 from: _build/prod/lib/exq applications: :kernel :stdlib :elixir :logger :redix :uuid includes: none logger-1.6.5 from: /Users/punitjain/.asdf/installs/elixir/1.6.5/bin/../lib/logger applications: :kernel :stdlib :elixir includes: none envy-1.1.1 from: _build/prod/lib/envy applications: :kernel :stdlib :elixir :logger includes: none cowlib-1.0.2 from: _build/prod/lib/cowlib applications: :kernel :stdlib :crypto includes: none asn1-5.0.3 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/asn1-5.0.3 applications: :kernel :stdlib includes: none public_key-1.5 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/public_key-1.5 applications: :asn1 :crypto :kernel :stdlib includes: none crypto-4.1 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/crypto-4.1 applications: :kernel :stdlib includes: none ssl-8.2.1 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/ssl-8.2.1 applications: :crypto :public_key :kernel :stdlib includes: none ranch-1.3.2 from: _build/prod/lib/ranch applications: :kernel :stdlib :ssl includes: none cowboy-1.1.2 from: _build/prod/lib/cowboy applications: :kernel :stdlib :ranch :cowlib :crypto includes: none compiler-7.1.3 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/compiler-7.1.3 applications: :kernel :stdlib includes: none elixir-1.6.5 from: /Users/punitjain/.asdf/installs/elixir/1.6.5/bin/../lib/elixir applications: :kernel :stdlib :compiler includes: none stdlib-3.4.2 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/stdlib-3.4.2 applications: :kernel includes: none kernel-5.4 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/kernel-5.4 applications: none includes: none trackbees-0.0.1 from: _build/prod/lib/trackbees applications: :kernel :stdlib :elixir :cowboy :envy :exq :gettext :logger :phoenix :phoenix_ecto :phoenix_html :phoenix_pubsub :postgrex :bamboo :timex :timex_ecto :inflex :sentry :quantum :slack :ex_aws :hackney :poison :ueberauth_identity :ueberauth_google includes: :envy :bamboo_smtp :basic_auth :canada :canary :comeonin :cors_plug :ecto_enum :edeliver :elixlsx :ex_admin :ex_aws_s3 :exgravatar :guardian :elixir_make :exactor :ffmpex :mogrify :phoenix_api_docs :rummage_ecto :secure_random :sweet_xml :thumbnex iex-1.6.5 from: /Users/punitjain/.asdf/installs/elixir/1.6.5/bin/../lib/iex applications: :kernel :stdlib :elixir includes: none sasl-3.1 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/sasl-3.1 applications: :kernel :stdlib includes: none runtime_tools-1.12.2 from: /usr/local/Cellar/erlang/20.1.5/lib/erlang/lib/runtime_tools-1.12.2 applications: :kernel :stdlib includes: none ==> Generated overlay vars: release_name=:trackbees release_version="0.0.1" 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="9.1.4" output_dir="_build/prod/rel/trackbees" ==> Copying applications to _build/prod/rel/trackbees ==> Generating nodetool ==> Generating start_erl.data ==> Generating vm.args ==> Generating sys.config from config/config.exs ==> Including ERTS 9.1.4 from /usr/local/Cellar/erlang/20.1.5/lib/erlang/erts-9.1.4 ==> Generating boot script ==> Generating RELEASES ==> Generating start_clean.boot ==> Generating no_dot_erlang.boot ==> Applying overlays ==> Applying mkdir overlay dst: releases/0.0.1/hooks ==> Applying mkdir overlay dst: releases/0.0.1/hooks/pre_configure.d ==> Applying mkdir overlay dst: releases/0.0.1/hooks/post_configure.d ==> Applying mkdir overlay dst: releases/0.0.1/hooks/pre_start.d ==> Applying mkdir overlay dst: releases/0.0.1/hooks/post_start.d ==> Applying mkdir overlay dst: releases/0.0.1/hooks/pre_stop.d ==> Applying mkdir overlay dst: releases/0.0.1/hooks/post_stop.d ==> Applying mkdir overlay dst: releases/0.0.1/hooks/pre_upgrade.d ==> Applying mkdir overlay dst: releases/0.0.1/hooks/post_upgrade.d ==> Applying copy overlay src: _build/prod/lib/distillery/priv/libexec dst: releases/0.0.1/libexec ==> Applying mkdir overlay dst: releases/0.0.1/commands ==> Packaging release.. ==> Archiving trackbees-0.0.1 ==> Writing tarball to _build/prod/rel/trackbees/releases/0.0.1/trackbees.tar.gz ==> Updating tarball ==> Tarball updated! ==> Release successfully built! You can run it in one of the following ways: Interactive: _build/prod/rel/trackbees/bin/trackbees console Foreground: _build/prod/rel/trackbees/bin/trackbees foreground Daemon: _build/prod/rel/trackbees/bin/trackbees start ```

What OS, Erlang/Elixir versions are you seeing this issue on?

MacOS version: 10.13.2, elixir: Elixir 1.6.5 (compiled with OTP 19), otp: Erlang/OTP 20

use Mix.Releases.Config,

This sets the default release built by mix release

default_release: :default,
# This sets the default environment used by `mix release`
default_environment: Mix.env()

For a full list of config options for both releases

and environments, visit https://hexdocs.pm/distillery/configuration.html

You may define one or more environments in this file,

an environment's settings will override those of a release

when building in that environment, this combination of release

and environment configuration is called a profile

environment :dev do

If you are running Phoenix, you should make sure that

server: true is set and the code reloader is disabled,

even in dev mode.

It is recommended that you build with MIX_ENV=prod and pass

the --env flag to Distillery explicitly if you want to use

dev mode.

set dev_mode: true set include_erts: false set cookie: :"TC__ke}MFh8DTsfg4E5;(7ob8h???wN@AIC<TYaJ4_yg).Q)V5[,PNysMr}S1q" end

environment :prod do set include_erts: true set include_src: false set cookie: :"lfHBC,7lDxe6kbZJ%M.x4=r!>[F*DhL)ly`?d$>%iE=9y)V4_Oulis?4Rvm)~!55" end

You may define one or more releases in this file.

If you have not set a default release, or selected one

when running mix release, the first release in the file

will be used by default

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



NOTE: I have already included all the application that are listed as dependencies but `:jsx` has some problem it was showing an exception when I add it in the `included_application`.
If you need any more information please let me know.
Any help/suggestion is appreciated 
bitwalker commented 6 years ago

You have a lot of dependencies in :included_applications, is that for a particular reason? If you aren't starting those manually, and they are required by your application, then things will definitely be broken. You should only use :included_applications if you truly need to control those applications lifecycles.

In any case, this looks like you are probably missing the requisite Phoenix configuration to start the server. You need to set server: true in the endpoint configuration in config.exs or prod.exs (usually the latter). Can you confirm whether that's the case? You can also run bin/trackbees remote_console and dump your config at the shell with Application.get_all_env(:trackbees)

punitcse commented 6 years ago

Sure I will remove included application. I have already add server: true in prod.ex file. Here is the output for Application.get_all_env(:trackbees)

....
{Trackbees.Endpoint,
   [
     secret_key_base: "hDq+GvvUL88RGa4oiTHODlb0oAQcGu041l9tF2DxEYzjDS0TyHQt7FxVI1RuDBIQ",
     render_errors: [view: Trackbees.ErrorView, accepts: ["html", "json"]],
     check_origin: false,
     pubsub: [name: Trackbees.PubSub, adapter: Phoenix.PubSub.PG2],
     http: [port: 4000],
     load_from_system_env: true,
     server: true,
     code_reloader: false
   ]},
...

I am wondering why I am not getting the url when I have added it to both config and prod.ex file.

bitwalker commented 6 years ago

I'm closing this for now. If you are able to find a reproduction with a smaller application, or can provide me access to this one, I can try to troubleshoot that way. My strong suspicion is that this is due to how you are using :included_applications, and something is being missed. Furthermore, :jsx is missing from the release, which is likely to cause issues - you need to fix that warning before we trying to reproduce. If you are adding :jsx to :included_applications, but not starting it, and other dependencies require it in their :applications lists, they will not start. You should avoid using :included_applications unless specifically needed - especially in the quantity seen, as the odds of conflicts are extremely high.

As far as the configuration issue goes, without seeing the original configuration files, I can't say why the value you are expecting isn't coming through. It may help to also know what version of Distillery this is happening with.

Feel free to reopen this issue if you can provide additional information that will help me troubleshoot (particularly a way to reproduce the case), but at this point I can neither reproduce, nor have enough information to provide much in the way of help, beyond the suggestions I've already made.