[erlang-questions] [Q] how to start httpd in R12B

Ladislav Lenart <>
Thu May 15 15:14:31 CEST 2008


Hello,

in R11B I used to start httpd server in my application top supervisor
via exported (but unsupported) httpd:start_link2/1 function which
no longer exist in R12B. So I changed it to httpd:start_standalone/1.
After all is started (db, inets, my supervisor which among other
things starts the HTTP server) I want to add default web users using
mod_auth:add_user/X. But this fails in gen_server:call/X because
the locally registered process httpd_auth_8008 does not exist.
I was trying to figure out who should start it (the mod_auth_server
module) from the sources but got lost on the way... :-(

My starting procedure is:
  1. Start mnesia (possibly creating a schema) and wait for tables.
  2. Start inets.
  3. Start my application which starts the top supervisor which
     starts the httpd. At this point, the only running HTTP related
     registered processes are:
       [httpc_sup,
        httpc_profile_sup,
        httpc_manager,
        httpc_handler_sup,
        httpd_sup].
  4. Ensure the default web users exist (crash).

The top supervisor init callback is (the interesting bit is WebSpec - httpd child spec):
init(Options) ->
     Environment = aw_options:read_option(environment, Options, aw_settings:read(environment, deployment)),
     WebSpec = {httpd,
	       {httpd, start_standalone, [aw_web:server_config(Environment)]},
	       transient,
	       infinity,
	       supervisor,
	       [httpd_sup]},
     MQSpec = {mqueue,
	      {aw_mqueue, start_link, []},
	      transient,
	      brutal_kill,
	      worker,
	      [aw_mqueue]},
     MailerOptions = aw_options:read_option(mailer, Options, aw_settings:read(mailer, [])),
     MailerSpec = {mailer,
		  {aw_mailer, start_link, [MailerOptions]},
		  transient,
		  5000,
		  worker,
		  [aw_mailer]},
     {ok, {{one_for_one, 10, 1}, [WebSpec, MQSpec, MailerSpec]}}.

My HTTP server configuration is (returned by aw_web:server_config/1,
mod_besi is our own extension):
[
      {server_name, ?server_name},
      {server_root, "/tmp"},
      {bind_address, ?listen_address},
      {port, Port},
      {document_root, document_root()},
      {mime_types, mime_types()},
      {directory_index, ["index.html"]},
      {besi_alias, {?mqueue_path, aw_web_mqueue}},
      {besi_alias, {?view_path, aw_web_view}},
      {besi_alias, {?edit_path, aw_web_edit}},
      {besi_environment, Environment},
      {directory, {?view_path, [{auth_name, ?admin_realm},
			      {auth_type, mnesia},
			      {allow_from, all},
			      {require_user, [?admin_view_user, ?admin_edit_user]}]}},
      {directory, {?edit_path, [{auth_name, ?admin_realm},
			      {auth_type, mnesia},
			      {allow_from, all},
			      {require_user, [?admin_edit_user]}]}},
      {directory, {?mqueue_path, [{allow_from, local_network()}]}},
      {modules, [mod_alias, mod_auth, mod_besi, mod_get, mod_head]}
]

The error message I get when starting my application is:
** exception error: no match of right hand side value
                     {error,
                      {bad_return,
                       {{aw_app,start,[normal,[]]},
                        {'EXIT',
                         {{badmatch,
                           {error,
                            {noproc,
                             {gen_server,call,
                              [httpd_auth_8008,
                               {add_user,undefined,8008,"/view",
                                [{httpd_user,"view",[...],...}],
                                "NoPassword"}]}}}},
                          [{aw_web,ensure_has_users,0},
                           {aw_app,start,2},
                           {application_master,start_it_old,4}]}}}}}
      in function  aw_app:start/1

Could someone please enlighten me?

Thanks in advance,

Ladislav Lenart





More information about the erlang-questions mailing list