Failing to start phoenix 1.3.0-rc with MIX_ENV=prod

I’m failing to start a newly generated phoenix app with MIX_ENV=prod on my machine. I’m not sure how to debug this (still learning elixir stuff).
Is there something obvious I’m missing?

Phoenix server starts just fine in dev mode (mix phx.server)
{:phoenix, "~> 1.3.0-rc"} and

$ elixir -v
Erlang/OTP 19 [erts-8.2.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Elixir 1.4.2

I’m creating and starting the app like this:

$ mix phx.new deploy_test
$ cd deploy_test
$ MIX_ENV=prod mix.compile

$ PORT=4000 MIX_ENV=prod mix phx.server                                                                                                                                              
{"Kernel pid terminated",application_controller,"{application_start_failure,deploy_test,{{shutdown,{failed_to_start_child,'Elixir.DeployTest.Web.Endpoint',{undef,[{'Elixir.Demo.Web.Endpoint',load_from_system_env,[[{endpoint_id,<<\"10RUlb/4dl1xcrP0L/5Vog==\">>},{otp_app,deploy_test},{handler,'Elixir.Phoenix.Endpoint.CowboyHandler'},{code_reloader,false},{debug_errors,false},{check_origin,true},{http,false},{https,false},{reloadable_compilers,[gettext,phoenix,elixir]},{static_url,nil},{watchers,[]},{render_errors,[{layout,false},{view,'Elixir.DeployTest.Web.ErrorView'},{accepts,[<<\"html\">>,<<\"json\">>]}]},{pubsub,[{pool_size,1},{name,'Elixir.DeployTest.PubSub'},{adapter,'Elixir.Phoenix.PubSub.PG2'}]},{on_init,{'Elixir.Demo.Web.Endpoint',load_from_system_env,[]}},{url,[{path,<<\"/\">>},{host,<<\"example.com\">>},{port,80}]},{cache_static_manifest,<<\"priv/static/cache_manifest.json\">>},{secret_key_base,<<\"JOLVbvEmNbR/7t6tOIhKGaFdsX/r21bvEeP9P2BCuUHaDn0r00UVPydgkqxgooah\">>}]],[]},{'Elixir.Phoenix.Endpoint.Supervisor',init,1,[{file,\"lib/phoenix/endpoint/supervisor.ex\"},{line,35}]},{supervisor,init,1,[{file,\"supervisor.erl\"},{line,294}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,247}]}]}}},{'Elixir.DeployTest.Application',start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,deploy_test,{{shutdown,{failed_to_start_child,'Elixir.DeployTest.Web.Endpoint',{undef,[{'Elixir.Demo.Web.Endpoint',load_from_

Crash dump is being written to: erl_crash.dump...done
1 Like

The error says, the function Demo.Web.Endpoint.load_from_system_env/1 is not defined.

1 Like

Check out the difference between 1.3.0-rc.0 and 1.3.0-rc.1 here:

https://www.phoenixdiff.org/diffs/1.3.0-rc.0/1.3.0-rc.1

You will see that the generator has been changed :

-  on_init: {Demo.Web.Endpoint, :load_from_system_env, []},
+  on_init: {SampleApp.Web.Endpoint, :load_from_system_env, []},

Open your prod.exs and replace the on_init key value by something that matches your app name, that will fix it.

2 Likes

Thanks a bunch guys, that was the problem :slight_smile:

2 Likes