erlang 如何调试phoenix框架的日志错误?

bttbmeg0  于 2022-12-16  发布在  Erlang
关注(0)|答案(2)|浏览(142)

我正在安装此Pheonix Web应用程序:https://github.com/poanetwork/blockscout
安装完所有依赖项后,我运行以下命令(遵循文档):

$ mix phx.server

字符串
并得到错误:

$ iex -S mix phx.server
Erlang/OTP 25 [erts-13.1.2] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit:ns]

2022-12-13T04:25:43.083 [notice] Application ethereum_jsonrpc exited: EthereumJSONRPC.Application.start(:normal, []) returned an error: shutdown: failed to start child: :worker
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, :badarg}
            (poolboy 1.5.2) /opt/app/blockscout/deps/poolboy/src/poolboy.erl:283: :poolboy.new_worker/1
            (poolboy 1.5.2) /opt/app/blockscout/deps/poolboy/src/poolboy.erl:304: :poolboy.prepopulate/3
            (poolboy 1.5.2) /opt/app/blockscout/deps/poolboy/src/poolboy.erl:153: :poolboy.init/3
            (stdlib 4.1.1) gen_server.erl:851: :gen_server.init_it/2
            (stdlib 4.1.1) gen_server.erl:814: :gen_server.init_it/6
            (stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
2022-12-13T04:25:43.106 [notice] Application poolboy exited: :stopped
2022-12-13T04:25:43.106 [notice] Application decorator exited: :stopped
2022-12-13T04:25:43.106 [notice] Application decimal exited: :stopped
2022-12-13T04:25:43.106 [notice] Application websocket_client exited: :stopped
2022-12-13T04:25:43.106 [notice] Application ex_abi exited: :stopped
2022-12-13T04:25:43.106 [notice] Application ex_keccak exited: :stopped
2022-12-13T04:25:43.106 [notice] Application rustler exited: :stopped
2022-12-13T04:25:43.107 [notice] Application timex exited: :stopped
2022-12-13T04:25:43.107 [notice] Application gettext exited: :stopped
2022-12-13T04:25:43.108 [notice] Application combine exited: :stopped
2022-12-13T04:25:43.110 [notice] Application tzdata exited: :stopped
2022-12-13T04:25:43.110 [notice] Application spandex_datadog exited: :stopped
2022-12-13T04:25:43.111 [notice] Application msgpax exited: :stopped
2022-12-13T04:25:43.111 [notice] Application spandex exited: :stopped
2022-12-13T04:25:43.111 [notice] Application plug exited: :stopped
2022-12-13T04:25:43.111 [notice] Application telemetry exited: :stopped
2022-12-13T04:25:43.112 [notice] Application plug_crypto exited: :stopped
2022-12-13T04:25:43.112 [notice] Application mime exited: :stopped
2022-12-13T04:25:43.112 [notice] Application eex exited: :stopped
2022-12-13T04:25:43.112 [notice] Application optimal exited: :stopped
2022-12-13T04:25:43.112 [notice] Application logger_file_backend exited: :stopped
2022-12-13T04:25:43.112 [notice] Application jason exited: :stopped
2022-12-13T04:25:43.112 [notice] Application httpoison exited: :stopped
2022-12-13T04:25:43.113 [notice] Application hackney exited: :stopped
2022-12-13T04:25:43.113 [notice] Application metrics exited: :stopped
2022-12-13T04:25:43.113 [notice] Application ssl_verify_fun exited: :stopped
2022-12-13T04:25:43.113 [notice] Application parse_trans exited: :stopped
2022-12-13T04:25:43.113 [notice] Application syntax_tools exited: :stopped
2022-12-13T04:25:43.113 [notice] Application mimerl exited: :stopped
2022-12-13T04:25:43.113 [notice] Application idna exited: :stopped
2022-12-13T04:25:43.113 [notice] Application unicode_util_compat exited: :stopped
2022-12-13T04:25:43.113 [notice] Application cowboy exited: :stopped
2022-12-13T04:25:43.114 [notice] Application ranch exited: :stopped
2022-12-13T04:25:43.114 [notice] Application cowlib exited: :stopped
2022-12-13T04:25:43.114 [notice] Application certifi exited: :stopped
** (Mix) Could not start application ethereum_jsonrpc: EthereumJSONRPC.Application.start(:normal, []) returned an error: shutdown: failed to start child: :worker
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, :badarg}
            (poolboy 1.5.2) /opt/app/blockscout/deps/poolboy/src/poolboy.erl:283: :poolboy.new_worker/1
            (poolboy 1.5.2) /opt/app/blockscout/deps/poolboy/src/poolboy.erl:304: :poolboy.prepopulate/3
            (poolboy 1.5.2) /opt/app/blockscout/deps/poolboy/src/poolboy.erl:153: :poolboy.init/3
            (stdlib 4.1.1) gen_server.erl:851: :gen_server.init_it/2
            (stdlib 4.1.1) gen_server.erl:814: :gen_server.init_it/6
            (stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

我发现没有源代码的堆栈跟踪,所有可以看到的堆栈跟踪都是依赖项的。
所以我问题是:如何知道此错误的which line of the source code发生在?
谢谢。

w7t8yxp5

w7t8yxp51#

错误发生在应用程序尝试启动之前。

  • ErlangVM* 尝试启动所有依赖于您的应用程序,并且错误
Application ethereum_jsonrpc exited:
     EthereumJSONRPC.Application.start(:normal, []) returned an error:
       shutdown: failed to start child: :worker
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, :badarg}

基本上意味着ethereum_jsonrpc应用程序无法启动,从而阻止ErlangVM尝试启动主应用程序。要缩小问题范围,可以尝试显式启动失败的ethereum_jsonrpc,例如从与Application.ensure_all_started(:ethereum_jsonrpc)或更显式的EthereumJSONRPC.Application.start(:normal, [])iex会话启动。

b91juud3

b91juud32#

好吧,我解决了。
最后我不知道哪一行代码失败了。

溶液

1.将许多调试日志打印到源代码中,并猜测在哪一步失败。

+    IO.puts "== config: #{ inspect config}"
+    IO.puts "== rolling_window_opts: #{ inspect rolling_window_opts}"

另外,在pheonix框架中,您可以从源代码文件的CalssName中猜出源代码文件,例如:
EthereumJSONRPC.ApplicationMap到apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/application.ex
2.更改记录器级别。
3.编辑config/config.exs文件以启用DB日志:

database: database_api,
   hostname: hostname_api,
   // add this line of code
   show_sensitive_data_on_connection_error: true

相关问题