【问题标题】:Starting inets/httpd with custom application使用自定义应用程序启动 inets/httpd
【发布时间】:2010-03-30 00:04:46
【问题描述】:

我有一个模块,我正试图将其转换为合适的 OTP 应用程序。目前,该模块有 start/0 ,它启动一个 genserver,它提供从配置文件读取的配置数据。然后它调用 inets:start(httpd,config:lookup(httpd_conf))。我收集到我需要将这些的开头移到 .app 文件的(应用程序列表)中,但我不确定如何将我的配置数据放入 inets:start 函数中(或传入 httpd)?

谢谢, --tim

【问题讨论】:

  • 我在思考我的问题可以通过参考这个[1] 文档然后提出问题来简化:“erlang 节点应用程序配置文件”到底是什么,它有什么名字,应该在哪里引用,去哪里?
  • 文档的链接未显示在您的评论中。请编辑。
  • 对不起,这里是:www1.erlang.org/doc/apps/inets/http_server.html#id2252622我已经取得了一些进展。我想如果我创建一个文件 inets.config,那么当我启动时,通过 -config inets.config 引用它,它会使用它。现在,我遇到了应该从该文件中引用的 proplists 文件(弄清楚应该放入其中的内容)的问题。谢谢...

标签: erlang


【解决方案1】:

这就是我想出的...

首先,我需要创建 inets 配置文件:

inets.config:
      [{inets, [{services, [{httpd, [{proplist_file,
             "8080.conf"}]},
     ].

然后,创建 httpd conf 文件:

8080.conf
[
{modules, [
 mod_alias, 
 mod_auth, 
 mod_esi, 
 mod_actions, 
 mod_cgi, 
 mod_dir, 
 mod_get, 
 mod_head, 
 mod_log, 
 mod_disk_log
]},
{port,8080},
{server_name,"hello_world"},
{server_root,"log"},
{document_root,"www"},
{erl_script_alias, {"/erl", [hello_world]}},
{error_log, "error.log"},
{security_log, "security.log"},
{transfer_log, "transfer.log"},
{mime_types,[
{"html","text/html"},
 {"css","text/css"},
{"js","application/x-javascript"}
]}
]

现在,在启动我的应用程序时,我只需引用 inets.conf 文件:

$ erl -boot start_sasl -pa ebin -config inets.config

这似乎工作不知道它是否是“正确”的方式......

【讨论】:

猜你喜欢
  • 2014-04-30
  • 2014-05-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-08
  • 1970-01-01
  • 2016-07-21
  • 2011-09-23
相关资源
最近更新 更多