Search code examples
elixirphoenix-frameworkexrm

Cannot start phoenix release


Yesterday I faced very strange problem.

Configuration:

- Erlang 19
- Elixir 1.3.1
- Exrm 1.0.6
- Phoenix 1.2.0
- Ubuntu 15.10

The steps:

  1. Compile project using MIX_ENV=prod mix compile
  2. Build release using MIX_ENV=prod mix release
  3. Try to test built project using rel/susu_online/bin/susu_online console

Then I get an error and can't figure out why this happens

Following error:

Erlang/OTP 19 [erts-8.0] [source-6dc93c1] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

10:37:29.758 [error] Supervisor 'Elixir.Logger.Supervisor' had child 'Elixir.Logger.ErrorHandler' started with 'Elixir.Logger.Watcher':watcher(error_logger, 'Elixir.Logger.ErrorHandler', {true,false,500}, link) at <0.1445.0> exit with reason normal in context child_terminated
10:37:29.767 [info] Application lager started on node '[email protected]'
10:37:29.767 [info] Application hpack started on node '[email protected]'
10:37:29.768 [info] Application chatterbox started on node '[email protected]'
10:37:29.768 [info] Application elixlsx started on node '[email protected]'
10:37:29.768 [info] Application poolboy started on node '[email protected]'
10:37:29.769 [info] Application poison started on node '[email protected]'
10:37:29.813 [info] Application apns started on node '[email protected]'
10:37:29.814 [info] Application httpoison started on node '[email protected]'
10:37:29.814 [info] Application pigeon started on node '[email protected]'
10:37:29.815 [info] Application combine started on node '[email protected]'
10:37:29.815 [info] Application gettext started on node '[email protected]'
10:37:29.815 [info] Application timex started on node '[email protected]'
10:37:29.815 [info] Application comeonin started on node '[email protected]'
10:37:29.816 [info] Application connection started on node '[email protected]'
10:37:29.816 [info] Application db_connection started on node '[email protected]'
10:37:29.816 [info] Application decimal started on node '[email protected]'
10:37:29.817 [info] Application postgrex started on node '[email protected]'
10:37:29.817 [info] Application ecto started on node '[email protected]'
10:37:29.818 [info] Application phoenix_ecto started on node '[email protected]'
10:37:29.818 [info] Application cowlib started on node '[email protected]'
10:37:29.818 [info] Application ranch started on node '[email protected]'
10:37:29.819 [info] Application cowboy started on node '[email protected]'
10:37:29.819 [info] Application plug started on node '[email protected]'
10:37:29.819 [info] Application phoenix_html started on node '[email protected]'
10:37:29.820 [info] Application eex started on node '[email protected]'
10:37:29.820 [info] Application phoenix started on node '[email protected]'
10:37:29.825 [info] Application susu_online exited: SusuOnline.start(:normal, []) returned an error: shutdown: failed to start child: SusuOnline.Endpoint
    ** (EXIT) shutdown: failed to start child: Phoenix.PubSub.PG2
        ** (EXIT) an exception was raised:
            ** (UndefinedFunctionError) function Phoenix.PubSub.PG2.start_link/2 is undefined (module Phoenix.PubSub.PG2 is not available)
                Phoenix.PubSub.PG2.start_link(SusuOnline.PubSub, [fastlane: Phoenix.Channel.Server, pool_size: 1, name: SusuOnline.PubSub, adapter: Phoenix.PubSub.PG2])
                (stdlib) supervisor.erl:365: :supervisor.do_start_child/2
                (stdlib) supervisor.erl:348: :supervisor.start_children/3
                (stdlib) supervisor.erl:314: :supervisor.init_children/2
                (stdlib) gen_server.erl:328: :gen_server.init_it/6
                (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
10:37:29.823 [error] Supervisor 'Elixir.SusuOnline.Endpoint' had child 'Elixir.Phoenix.PubSub.PG2' started with 'Elixir.Phoenix.PubSub.PG2':start_link('Elixir.SusuOnline.PubSub', [{fastlane,'Elixir.Phoenix.Channel.Server'},{pool_size,1},{name,'Elixir.SusuOnline.PubSub'},{adapter,...}]) at undefined exit with reason {'EXIT',{undef,[{'Elixir.Phoenix.PubSub.PG2',start_link,['Elixir.SusuOnline.PubSub',[{fastlane,'Elixir.Phoenix.Channel.Server'},{pool_size,1},{name,'Elixir.SusuOnline.PubSub'},{adapter,'Elixir.Phoenix.PubSub.PG2'}]],[]},{supervisor,do_start_child,2,[{file,"supervisor.erl"},{line,365}]},{supervisor,start_children,3,[{file,"supervisor.erl"},{line,348}]},{supervisor,init_children,2,[{file,"supervisor.erl"},{line,314}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,328}]},{proc_lib,init_p_do_apply,...}]}} in context start_error
{"Kernel pid terminated",application_controller,"{application_start_failure,susu_online,{{shutdown,{failed_to_start_child,'Elixir.SusuOnline.Endpoint',{shutdown,{failed_to_start_child,'Elixir.Phoenix.PubSub.PG2',{'EXIT',{undef,[{'Elixir.Phoenix.PubSub.PG2',start_link,['Elixir.SusuOnline.PubSub',[{fastlane,'Elixir.Phoenix.Channel.Server'},{pool_size,1},{name,'Elixir.SusuOnline.PubSub'},{adapter,'Elixir.Phoenix.PubSub.PG2'}]],[]},{supervisor,do_start_child,2,[{file,\"supervisor.erl\"},{line,365}]},{supervisor,start_children,3,[{file,\"supervisor.erl\"},{line,348}]},{supervisor,init_children,2,[{file,\"supervisor.erl\"},{line,314}]},{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.SusuOnline',start,[normal,[]]}}}"}

Crash dump is being written to: erl_crash.dump...done
Kernel pid terminated (application_controller) ({application_start_failure,susu_online,{{shutdown,{failed_to_start_child,'Elixir.SusuOnline.Endpoint',{shutdown,{failed_to_start_child,'Elixir.Phoenix.P

The line ** (EXIT) shutdown: failed to start child: Phoenix.PubSub.PG2 is extremely confuses me. Why project cannot find its own module?


Solution

  • You usually see this problem when using a release when an application is missing from the applications list.

    Do you have phoenix_pubsub inside the applications list in your mix.exs?

    It should looks something like:

      def application do
        [mod: {MyApp, []},
         applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext,
                        :phoenix_ecto, :postgrex]]
      end