inets httpd:服务器配置文件语法(proplist_file)

时间:2018-02-26 14:58:17

标签: erlang inets

启动这样的httpd服务器时配置文件的语法是什么:

inets:start(httpd, 
    [{proplist_file, "./server_config.txt"}]
).

httpd docs说:

  

{proplist_file,path()}

     

如果定义了此属性,Inets希望找到所有其他属性   此文件中定义的属性。

  

要从可以的配置文件中提取属性   由常规的Erlang属性列表组成

但是有了这个文件:

server_config.txt:

[
  {port, 0},
  {server_name, "httpd_test"},
  {server_root, "/Users/7stud/erlang_programs/inets_proj"},
  {document_root, "/Users/7stud/erlang_programs/inets_proj/htdocs"},
  {ipfamily, inet6},
  { bind_address, {0,0,0,0,0,0,0,1} }
]

我收到错误:

$ erl
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.2  (abort with ^G)

1> inets:start().
ok

2> inets:start(httpd, [{proplist_file, "/Users/7stud/erlang_programs/inets_proj/server_config.txt"}]).
** exception error: no try clause matching {error,{8,erl_parse,["syntax error before: ",[]]}}
     in function  httpd_sup:httpd_config/1 (httpd_sup.erl, line 144)
     in call from httpd_sup:start_child/1 (httpd_sup.erl, line 52)
     in call from inets:call_service/3 (inets.erl, line 461)

接下来,我尝试了Apache语法,但这也不起作用:

server_config.txt:

Port 0
ServerName "httpd_test"
ServerRoot "/Users/7stud/erlang_programs/inets_proj"
DocumentRoot "./htdocs"
Ipfamily inet6
BindAddress {0,0,0,0,0,0,0,1}
3> inets:start(httpd, [{file, "./server_config.txt"}]).         
{error,"httpd_conf: \"/Users/7stud/erlang_programs/inets_proj\" is an invalid ServerRoot"}

4>

好的,我通过删除引号在Apache样式语法上取得了一些进展:

Port 0
ServerName httpd_test
ServerRoot /Users/7stud/erlang_programs/inets_proj
DocumentRoot ./htdocs
Ipfamily inet6
BindAddress 0:0:0:0:0:0:0:1

现在,我收到错误:

8> inets:start(httpd, [{file, "./server_config.txt"}]).
{error,"httpd_conf: 0:0:0:0:0:0:0:1 is an invalid address"}

0 个答案:

没有答案