2016-01-06 41 views
1

我遇到了部署在heroku上的鳳凰應用程序的問題。當我在本地運行此代碼時,一切正常,沒有錯誤。當部署到Heroku上,應用程序成功部署並啓動,但使用的應用程序時,GenServer的過程與此錯誤崩潰:Heroku上的Elixir應用程序**(ErlangError)erlang錯誤::「功能未導出」

[error] GenServer :main_worker terminating 
** (exit) an exception was raised: 
    ** (ErlangError) erlang error: :"function not exported" 
     (elixir) Map.get_and_update!(%{"location" => %{"latitude" => 35.9628632, "longitude" => -86.8216522}, "name" => "Dover", "pickups" => 0}, "pickups", #Function<0.62518121/1 in BusTracker.MainWorker.handle_call/3>) 
     (bus_tracker) lib/bus_tracker/main_worker.ex:27: BusTracker.MainWorker.handle_call/3 
     (stdlib) gen_server.erl:629: :gen_server.try_handle_call/4 
     (stdlib) gen_server.erl:661: :gen_server.handle_msg/5 
     (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3 
13:25:03.112 [error] GenServer #PID<0.319.0> terminating 
** (exit) an exception was raised: 
    ** (ErlangError) erlang error: {{:undef, [{Map, :get_and_update!, [%{"location" => %{"latitude" => 35.9628632, "longitude" => -86.8216522}, "name" => "Dover", "pickups" => 0}, "pickups", #Function<0.62518121/1 in BusTracker.MainWorker.handle_call/3>], []}, {BusTracker.MainWorker, :handle_call, 3, [file: 'lib/bus_tracker/main_worker.ex', line: 27]}, {:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 629]}, {:gen_server, :handle_msg, 5, [file: 'gen_server.erl', line: 661]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}, {GenServer, :call, [:main_worker, {:update_pickups, {"Dover", 1}}, 5000]}} 
     (elixir) lib/gen_server.ex:356: GenServer.call/3 
     (bus_tracker) web/channels/main_channel.ex:38: BusTracker.MainChannel.handle_in/3 
     (phoenix) lib/phoenix/channel/server.ex:210: Phoenix.Channel.Server.handle_info/2 
     (stdlib) gen_server.erl:615: :gen_server.try_dispatch/4 
     (stdlib) gen_server.erl:681: :gen_server.handle_msg/5 
     (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3 

這裏有是代碼的錯誤引用。

defmodule BusTracker.MainWorker do 
    use GenServer 
    # . . . 

    # Server 
25> def handle_call({:update_pickups, {name,num}}, _, state) do 
26> waypoint = state.waypoints[name] 
27> {_, new_waypoint} = Map.get_and_update! waypoint, "pickups", fn(val) -> {"pickups", val + num} end 
28> {_, new_waypoints} = Map.get_and_update! state.waypoints, name, fn(val) -> {name, new_waypoint} end 
29> {_, new_state}  = Map.get_and_update! state, :waypoints , fn(val) -> {:waypoints, new_waypoints} end 
30> {:reply, new_waypoint["pickups"], new_state} 
31> end 
    # . . . 
    end 

我使用這些Heroku的建立包:

  • github.com/HashNuke/heroku-buildpack-elixir.git
  • github.com/gjaldon/heroku-buildpack-phoenix- static.git

這裏是我elixir_buildpack.config:

# Erlang version 
erlang_version=18.1.3 

# Elixir version 
elixir_version=1.0.4 

# Always rebuild from scratch on every deploy? 
always_rebuild=false 

# Export heroku config vars 
# config_vars_to_export=(DATABASE_URL) 

# A command to run right after compiling the app 
post_compile="pwd" 

Aug 5th, 2015的elixir irc頻道中提到了這一點,但我無法弄清楚如何通過討論來解決問題。我是長生不老的新手,有人可以幫我一些嗎?謝謝

+0

您是否在本地運行與您在buildpack中定義的Elixir和Erlang相同版本? – Gazler

+0

哇,總新手錯誤。這些版本實際上是不同的,所以我更新到構建包中的Elixir 1.1.1,問題就消失了。謝謝@Gazler! –

+1

你應該把Gazler的答案標記爲「可以接受」。 –

回答

2

確保您在開發環境中使用的Heroku上使用的Elixir和Erlang版本相同。

# Erlang version 
erlang_version=18.1.3 

# Elixir version 
elixir_version=1.1.1