Launch Phoenix application release with exrm errors

I am trying to create a Phoenix stock application release (based on Elixir and Erlang) using exrm .

The first release for the dev mixing environment is excellent, but it fails to start using the ./rel/my_app/bin/my_app console . This happens when you start Ubuntu 14.04 inside the Vagrant / Virtual Box virtual machine.

On my Mac, the same setup works fine. Unfortunately, I need to create a release on a machine with the same architecture as the target server on which Ubuntu will be running.

The app can be found here: https://github.com/mavenastic/my_app . It includes the steps taken to install the dependencies and create the project in the virtual machine (see STEPS.md ), as well as the Erlang crash .

Here is the error I get from trying to start the console:

 {"Kernel pid terminated",application_controller,"{application_start_failure,my_app,{{shutdown,{failed_to_start_child,'Elixir.MyApp.Endpoint',{shutdown,{failed_to_start_child,'Elixir.Phoenix.CodeReloader.Server',{undef,[{'Elixir.Mix.Project',config,[],[]},{'Elixir.Phoenix.CodeReloader.Server',init,1,[{file,\"lib/phoenix/code_reloader/server.ex\"},{line,29}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,240}]}]}}}}},{'Elixir.MyApp',start,[normal,[]]}}}"} 

EDIT:

I tried to create a release for the production environment, as well as with MIX_ENV=prod mix release . The release was successfully generated and MIX_ENV=prod PORT=8889 ./rel/my_app/bin/my_app console working fine. However, I cannot ping the server or start the remote console after it starts, so it seems that the application still does not work correctly.

 $ MIX_ENV=prod PORT=8889 ./rel/my_app/bin/my_app start $ MIX_ENV=prod PORT=8889 ./rel/my_app/bin/my_app ping =INFO REPORT==== 24-Oct-2015::10:28:25 === Protocol: "inet_tcp": register/listen error: econnrefused escript: exception error: no match of right hand side value {error, {{shutdown, {failed_to_start_child,net_kernel, {'EXIT',nodistribution}}}, {child,undefined,net_sup_dynamic, {erl_distribution,start_link, [[' my_app_maint_2551@127.0.0.1 ',longnames]]}, permanent,1000,supervisor, [erl_distribution]}}} $ ps aux | grep my_app vagrant 2572 0.0 0.0 7532 96 ? S 10:28 0:00 /vagrant/my_app/rel/my_app/erts-7.1/bin/epmd -daemon vagrant 2575 0.0 0.2 9448 2256 pts/0 S+ 10:28 0:00 grep --color=auto my_app $ MIX_ENV=prod PORT=8889 ./rel/my_app/bin/my_app remote_console $ 

Also, from what I have compiled, I would have to create a release for dev or any other environment. Thus, the missing part can affect both environments.

Thanks in advance!

+5
source share
4 answers

Assuming @bitwalker using the master exrm branch, the problem is fixed.

0
source

It seems to me that the problem is that you are creating a release in your dev environment (instead of prod env).

This part:

 {undef,[{'Elixir.Mix.Project',config,[],[]} 

the error message (awful and awful ร  la Erlang) basically says that Mix.Project.config/0 is undefined. Mix is โ€‹โ€‹not included in releases, but I assume that Phoenix uses it in its code loader, which you usually donโ€™t run during production.

Try creating the release using MIX_ENV=prod and see if it works.

+2
source

I put this in the problem tracker, but only for posterity here:

You need to add server: true to prod.exs as configured for MyApp.Endpoint . This is how Phoenix begins itself as part of the release.

With Phoenix, I would always recommend using MIX_ENV=prod for releases, MIX_ENV=dev has many design features (for example, code reloading) that either will not work in the release or will not work as expected.

If you get configuration errors, perhaps because you are missing any necessary Phoenix configuration in your environment-specific file. You can verify this by running MIX_ENV=prod mix compile to see if it compiles successfully. You can also create your own release using --verbosity=verbose to get verbose output for problem tracking.

The reason you couldn't run the ping or console command to release is because it failed at startup.

+1
source

@bitwalker is correct, you should add server: true in your config/prod.exs file server: true a la http://www.phoenixframework.org/v0.13.1/docs/advanced-deployment .

I cloned your project and generated a dev release and I get the same failure. I got the same error in many of my personal projects using the dev build. However, the prod construct always works.

Thus, after placing config/prod.secret.exs with the correct information in it and adding the server: true file to my config/prod.exs , I can generate the prod release and execute console , start and ping successfully. I suspect that the overheating of hot code may be the culprit of the dev assembly, but has no evidence to preclude its presence in the error and, definitely, something that is different from dev vs prod .

BTW, when you start the application, you need to specify only PORT , not MIX_ENV , since this is a release, and the mix does not play:

PORT=4000 bin/my_app start

My advice is to skip the dev assembly and just use the staging and prod construct. If you do not have a staging server, you can deploy the staging edition to the local computer a la https://exrm.readme.io/docs/deployment .

+1
source

Source: https://habr.com/ru/post/1234427/


All Articles