无法启动凤凰发布

时间:2016-07-08 06:56:51

标签: elixir phoenix-framework exrm

昨天我遇到了一个非常奇怪的问题。

配置:

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

步骤:

  1. 使用MIX_ENV=prod mix compile
  2. 编译项​​目
  3. 使用MIX_ENV=prod mix release
  4. 构建版本
  5. 尝试使用rel/susu_online/bin/susu_online console
  6. 测试已构建的项目

    然后我收到错误,无法弄清楚为什么会发生这种情况

    以下错误:

    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 'susu_online@127.0.0.1'
    10:37:29.767 [info] Application hpack started on node 'susu_online@127.0.0.1'
    10:37:29.768 [info] Application chatterbox started on node 'susu_online@127.0.0.1'
    10:37:29.768 [info] Application elixlsx started on node 'susu_online@127.0.0.1'
    10:37:29.768 [info] Application poolboy started on node 'susu_online@127.0.0.1'
    10:37:29.769 [info] Application poison started on node 'susu_online@127.0.0.1'
    10:37:29.813 [info] Application apns started on node 'susu_online@127.0.0.1'
    10:37:29.814 [info] Application httpoison started on node 'susu_online@127.0.0.1'
    10:37:29.814 [info] Application pigeon started on node 'susu_online@127.0.0.1'
    10:37:29.815 [info] Application combine started on node 'susu_online@127.0.0.1'
    10:37:29.815 [info] Application gettext started on node 'susu_online@127.0.0.1'
    10:37:29.815 [info] Application timex started on node 'susu_online@127.0.0.1'
    10:37:29.815 [info] Application comeonin started on node 'susu_online@127.0.0.1'
    10:37:29.816 [info] Application connection started on node 'susu_online@127.0.0.1'
    10:37:29.816 [info] Application db_connection started on node 'susu_online@127.0.0.1'
    10:37:29.816 [info] Application decimal started on node 'susu_online@127.0.0.1'
    10:37:29.817 [info] Application postgrex started on node 'susu_online@127.0.0.1'
    10:37:29.817 [info] Application ecto started on node 'susu_online@127.0.0.1'
    10:37:29.818 [info] Application phoenix_ecto started on node 'susu_online@127.0.0.1'
    10:37:29.818 [info] Application cowlib started on node 'susu_online@127.0.0.1'
    10:37:29.818 [info] Application ranch started on node 'susu_online@127.0.0.1'
    10:37:29.819 [info] Application cowboy started on node 'susu_online@127.0.0.1'
    10:37:29.819 [info] Application plug started on node 'susu_online@127.0.0.1'
    10:37:29.819 [info] Application phoenix_html started on node 'susu_online@127.0.0.1'
    10:37:29.820 [info] Application eex started on node 'susu_online@127.0.0.1'
    10:37:29.820 [info] Application phoenix started on node 'susu_online@127.0.0.1'
    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
    

    ** (EXIT) shutdown: failed to start child: Phoenix.PubSub.PG2行让我非常困惑。为什么项目找不到自己的模块?

1 个答案:

答案 0 :(得分:7)

在应用程序列表中缺少应用程序时,通常会在使用发行版时看到此问题。

你在mix.exs的应用程序列表中有phoenix_pubsub吗?

它应该看起来像:

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