翻译erlang的记录器事件失败

时间:2018-09-13 05:11:29

标签: elixir phoenix-framework

设置新的Phoenix项目(使用最新版本的Phoenix和Elixir 1.7.3)后,所有默认测试均通过,但是当我查询缺少的端点(/或/ api)时,服务器崩溃,并显示以下消息(相反)显示错误页面):

[info] Running LeiaphxWeb.Endpoint with Cowboy using http://0.0.0.0:4000
[info] GET /api
[error] Failure while translating Erlang's logger event
** (Protocol.UndefinedError) got FunctionClauseError with message "no function clause matching in Plug.Exception.__protocol__/1" while retrieving Exception.message/1 for %Protocol.UndefinedError{description: "", protocol: Plug.Exception, value: %Protocol.UndefinedError{description: "", protocol: Plug.Exception, value: %Protocol.UndefinedError{description: "", protocol: Plug.Exception, value: %Phoenix.Router.NoRouteError{conn: %Plug.Conn{adapter: {Plug.Adapters.Cowboy.Conn, {:http_req, #Port<0.18>, :ranch_tcp, :keepalive, #PID<0.379.0>, "GET", :"HTTP/1.1", {{172, 18, 0, 1}, 47700}, "localhost", :undefined, 4000, "/api", :undefined, "", :undefined, [], [{"host", "localhost:4000"}, {"connection", "keep-alive"}, {"cache-control", "max-age=0"}, {"upgrade-insecure-requests", "1"}, {"user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.183 Safari/537.36 Vivaldi/1.96.1147.64"}, {"accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"}, {"dnt", "1"}, {"accept-encoding", "gzip, deflate, br"}, {"accept-language", "en-US,en;q=0.9"}], [{"connection", ["keep-alive"]}], :undefined, [], :waiting, "", :undefined, false, :waiting, [], "", #Function<1.5539822/4 in Plug.Adapters.Cowboy.add_on_response/3>}}, assigns: %{}, before_send: [#Function<1.19958193/1 in Plug.Logger.call/2>], body_params: %{}, cookies: %Plug.Conn.Unfetched{aspect: :cookies}, halted: false, host: "localhost", method: "GET", owner: #PID<0.379.0>, params: %{}, path_info: ["api"], path_params: %{}, peer: {{172, 18, 0, 1}, 47700}, port: 4000, private: %{LeiaphxWeb.Router => {[], %{}}, :phoenix_endpoint => LeiaphxWeb.Endpoint, :phoenix_router => LeiaphxWeb.Router, :plug_session_fetch => #Function<1.131660147/1 in Plug.Session.fetch_session/1>}, query_params: %{}, query_string: "", remote_ip: {172, 18, 0, 1}, req_cookies: %Plug.Conn.Unfetched{aspect: :cookies}, req_headers: [{"host", "localhost:4000"}, {"connection", "keep-alive"}, {"cache-control", "max-age=0"}, {"upgrade-insecure-requests", "1"}, {"user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.183 Safari/537.36 Vivaldi/1.96.1147.64"}, {"accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"}, {"dnt", "1"}, {"accept-encoding", "gzip, deflate, br"}, {"accept-language", "en-US,en;q=0.9"}], request_path: "/api", resp_body: nil, resp_cookies: %{}, resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}], scheme: :http, script_name: [], secret_key_base: "xgicn8VJUGEQM5PcJLmB2CPURTvr0oxsetSR/Bq3Y3jLty0gRoV3woN2wZPDcYX5", state: :unset, status: nil}, message: "no route found for GET /api (LeiaphxWeb.Router)", plug_status: 404, router: LeiaphxWeb.Router}}}}
    (plug) lib/plug/exceptions.ex:4: Plug.Exception.impl_for!/1
    (plug) lib/plug/exceptions.ex:19: Plug.Exception.status/1
    (plug) lib/plug/adapters/translator.ex:79: Plug.Adapters.Translator.non_500_exception?/1
    (plug) lib/plug/adapters/translator.ex:49: Plug.Adapters.Translator.translate_ranch/5
    (logger) lib/logger/erlang_handler.ex:104: Logger.ErlangHandler.translate/6
    (logger) lib/logger/erlang_handler.ex:97: Logger.ErlangHandler.translate/5
    (logger) lib/logger/erlang_handler.ex:30: anonymous fn/3 in Logger.ErlangHandler.log/2
    (logger) lib/logger.ex:861: Logger.normalize_message/2
    (logger) lib/logger.ex:684: Logger.__do_log__/3
    (kernel) logger_backend.erl:51: :logger_backend.call_handlers/3
    (kernel) logger_backend.erl:38: :logger_backend.log_allowed/2
    (ranch) /app/deps/ranch/src/ranch_conns_sup.erl:167: :ranch_conns_sup.loop/4
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

这是Phoenix中的错误,还是我做错了什么? 如果相关,该应用程序将在Docker容器内运行。

1 个答案:

答案 0 :(得分:0)

我不确定这是否是问题所在,但是在尝试在本地计算机(没有Docker)上重新创建堆栈时,我缺少了inotify-tools。当我重新创建项目并将其添加到我的Dockerfile中时,它开始工作了!