【问题标题】:How to get more information about error when starting Inets httpd?启动 Inets httpd 时如何获取有关错误的更多信息?
【发布时间】:2014-04-30 21:41:18
【问题描述】:

我通过以下方式启动 Inets http:

> inets:start(httpd, [{port, 8060}, {server_name, "myserver"},
> {server_root, "/Users/jonas/code"},                         
> {document_root, "/Users/jonas/code/mydocs"},             
> {bind_address, {192, 168, 2, 5}}]).                         
{error,inets_not_started}

所以我拥有的唯一错误信息是{error,inets_not_started}。有什么方法可以让我获得有关问题所在的更多信息?

【问题讨论】:

    标签: erlang inets


    【解决方案1】:

    这是一个很好的问题,因为不幸地重载了 inets:start/[0,1,2,3] 函数并且 httpc documentation 不是很清楚启动 inets 也会自动启动 httpc 服务。

    尤其是当 on 只是跳转到HTTP CLIENT SERVICE START/STOP 部分以快速上手,从而错过了the module description 中的注释。

    • inets:start/[0,1] 启动 inets 应用程序本身使用名为 default 的默认配置文件的 httpc 服务(仅记录在 httpc 中)。

    • inets:start/[2,3](应该称为start_service)启动可以在inets(即ftpctftphttpc、@)上运行的服务之一987654345@) 一旦inets 应用程序已经启动

    start() ->
    start(Type) -> ok | {error, Reason}

        启动 Inets 应用程序。

    start(Service, ServiceConfig) -> {ok, Pid} | {error, Reason}
    start(Service, ServiceConfig, How) -> {ok, Pid} | {error, Reason}

        在之后动态启动 Inets 服务 Inets 应用程序已启动
    inets:start/[0,1])。


    关于httpc的注意事项

    从上方httpc module documentation

    启动 Inets 应用程序时,会启动默认配置文件的管理器进程。此 API 中未明确使用配置文件的函数会访问默认配置文件。

    也就是说,httpc 服务将使用名为 default 的默认配置文件自动启动。

    1> inets:start().
    ok
    2> httpc:get_options(all, default).
    {ok,[{proxy,{undefined,[]}},
         {https_proxy,{undefined,[]}},
         {pipeline_timeout,0},
         {max_pipeline_length,2},
         {max_keep_alive_length,5},
         {keep_alive_timeout,120000},
         {max_sessions,2},
         {cookies,disabled},
         {verbose,false},
         {ipfamily,inet},
         {ip,default},
         {port,default},
         {socket_opts,[]},
         {unix_socket,undefined}]}
    3>
    3> inets:start(httpc, [{profile, lofa}]).
    {ok,<0.95.0>}
    4>
    5> httpc:get_options(all, default).
    {ok,[...]}
    6> httpc:get_options(all, lofa).
    {ok,[...]}
    

    有趣的是,当使用不存在的配置文件时,错误消息是inets_not_started

    7> httpc:get_options(all, balabab).
    {error,inets_not_started}
    

    【讨论】:

      【解决方案2】:

      start(Service, ServiceConfig, How) -> {ok, Pid} | {错误,原因}

      Dynamically starts an inets service after the inets application has been started. 
      

      所以你需要先调用这个函数。

      开始()-> 开始(类型)-> 确定 | {错误,原因}

      类型: 类型 = 永久 |瞬态 |临时的

       Starts the Inets application.
      

      【讨论】:

        【解决方案3】:

        您需要先致电inets:start/0。详情请见the inets documentation

        【讨论】:

          【解决方案4】:

          首先,要解决您的问题,只需通过以下方式启动inets 应用程序(错误原因表明它没有启动):

          inets:start().
          

          其次,一般来说,从 SASL application 开始会提高 Erlang/OTP 错误/崩溃的一点可读性 - 但这里并非如此。

          【讨论】:

            猜你喜欢
            • 2014-04-30
            • 1970-01-01
            • 2016-05-10
            • 1970-01-01
            • 2020-04-24
            • 2015-12-09
            • 1970-01-01
            • 2016-01-29
            相关资源
            最近更新 更多