It's not supposed to be started as an OTP application, you're supposed
to use mochiweb_http in your own supervisor(s). It doesn't really make
sense to do that since it's not a general web server, and it's much
easier to configure it in your own supervisor than with the
application configuration junk in OTP.
The fact that it has mochiweb_sup, mochiweb_app, etc. is pretty much
just because of the template I was starting from. Maybe someday we'll
find something intelligent to do with that (like start up a demo that
serves up documentation).
-bob
To expand on that, this is the basic pattern that we use:
%% Application's web code
-module(webapp_web).
-export([start/1, http/1]).
start(Options) ->
mochiweb_http:start([{name, ?MODULE}, {loop, {?MODULE, loop}} | Options]).
loop(Req) ->
Req:ok({"text/plain", "It worked!"}).
%% Application's supervisor
-module(webapp_sup).
-export([init/1, start_link/0]).
-behaviour(supervisor).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
WebConfig = [{port, 8080}],
Web = {webapp_web,
{webapp_web, start, [WebConfig]},
permanent, 5000, worker, dynamic},
Processes = [Web],