【问题标题】:How to determining why an Erlang application is not starting?如何确定 Erlang 应用程序没有启动的原因?
【发布时间】:2011-01-02 17:05:30
【问题描述】:

我正在尝试启动一个失败的 Erlang 应用程序。我在 shell 中看到的只是:

=INFO REPORT==== 7-Jan-2010::17:37:42 ===
    application: ui
    exited: {shutdown,{ui_app,start,[normal,[]]}}
    type: temporary

如何让 Erlang 向我提供有关应用程序未启动原因的更多信息?目前在 shell 中没有其他输出。

【问题讨论】:

    标签: erlang


    【解决方案1】:

    您可以尝试启动带有更多日志记录支持的 shell:

    erl -boot start_sasl

    这可能会提供更多细节。

    【讨论】:

    • 如果你已经有一个打开的 Erlang shell 然后输入:application:start(sasl)。
    • 这似乎对应用程序启动失败没有任何影响。 (我从 shell 运行 application:start(sasl)。)
    【解决方案2】:

    版本 R16B 中包含 patch (tp/supervisor-pass-on-errors)。此补丁使退出原因出现在应用程序停止日志消息中,因此比我们迄今为止所拥有的{shutdown,{ui_app,start,[normal,[]]}} 样式消息更有用。

    这是README中的条目:

    OTP-10490  == stdlib ==
    
        If a child process fails in its start function, then the
        error reason was earlier only reported as an error report
        from the error_handler, and supervisor:start_link would only
        return {error,shutdown}. This has been changed so the
        supervisor will now return {error,{shutdown,Reason}}, where
        Reason identifies the failing child and its error reason.
        (Thanks to Tomas Pihl)
    

    【讨论】:

    • 它也没有进入 R15B03,但它在 R16B01 中。此更改非常有用。
    【解决方案3】:

    这很痛苦,但我这样做是老式的方式,通过将 io:format's 写入应用程序的启动函数(即具有应用程序行为的模块代码)并计算出哪一行失败:(

    有时蛮力和无知是你唯一的人......

    【讨论】:

    • 是的 - 我 讨厌 在代码中粘贴 io:formats 只是为了找出崩溃的位置...... Erlang 堆栈跟踪将为这些类型提供准确的行号堆栈跟踪在其他语言中所做的事情。
    • 与其使用 io:format,不如使用 eunit 调试宏,例如 ?debugHere()、?debugVal(Val)、?debugMsg(Msg) 或 ?debugFmt(String, [Arg1, Arg2, ...])。
    • 好吧,既然这条评论是我写的 - Erlang 的新版本 (R15B) 现在在堆栈跟踪中包含行号。
    猜你喜欢
    • 2020-10-02
    • 2017-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-01
    • 2011-09-15
    相关资源
    最近更新 更多