1

I've got a module that I'm attempting to turn into a proper OTP application. Currently, the module has start/0 which starts a genserver which supplies configuration data read from a config file. It then calls inets:start(httpd,config:lookup(httpd_conf)). I gather that I need to move the starting of these out into the .app file's (application list) but I'm not sure how to get my config data into the inets:start function (or pass in httpd)?

Thanks, --tim

Tim
  • 323
  • 1
  • 3
  • 14
  • I'm *thinking* my question might be simplified by referring to this[1] documentation and then asking the question: What exactly is the "erlang node application configuration file", what name does it get, where should it be referenced, and where does it go? – Tim Mar 29 '10 at 15:02
  • The link to the doc doesn't show up in your comment. Please edit. – Roberto Aloi Mar 29 '10 at 15:41
  • Sorry about that here it is: http://www1.erlang.org/doc/apps/inets/http_server.html#id2252622 I've made a bit of progress. I've figured that if I create a file inets.config then when I go to boot up, reference it via -config inets.config, it uses it. Now, I'm having problems with the proplists file (figuring out what exactly should go into it) that is supposed to be referenced from that one. thanks... – Tim Mar 29 '10 at 15:46

1 Answers1

1

Here's what I've figured out...

First, I needed to create the inets config file:

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

Then, create the httpd conf file:

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"}
]}
]

Now, when booting my app, I just reference the inets.conf file with:

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

This seems to work not sure if it's the "right" way or not...

Tim
  • 323
  • 1
  • 3
  • 14
  • I finally found an example of the server config syntax! But even when I eliminate the file name at the top, the syntax doesn't work for me. Here's what worked for me: https://stackoverflow.com/questions/48991314/inets-httpd-server-configuration-file-syntax/48998263#48998263 – 7stud Feb 26 '18 at 22:42