Your child process config should have the following form:
{Name,
{webmachine_mochiweb, start, [WebConfig]},
permanent, 5000, worker, [mochiweb_socket_server]}
where Name
and WebConfig
must be unique to your webmachine instance. The WebConfig
part should include name
and dispatch_group
properties. For example:
WebConfig = [{name,instance1},
{dispatch_group,instance1},
{ip, Ip},
{port, Port},
{log_dir, "priv/log"},
{dispatch, Dispatch}],
So, for multiple instances you might have something like this for your supervisor spec:
WebConfig1 = [{name,instance1},
{dispatch_group,instance1},
{ip, Ip},
{port, Port},
{log_dir, "priv/log"},
{dispatch, Dispatch}],
WebConfig2 = [{name,instance2},
{dispatch_group,instance2},
{ip, Ip},
{port, Port+1},
{log_dir, "priv/log"},
{dispatch, Dispatch}],
Web1 = {instance1,
{webmachine_mochiweb, start, [WebConfig1]},
permanent, 5000, worker, [mochiweb_socket_server]},
Web2 = {instance2,
{webmachine_mochiweb, start, [WebConfig2]},
permanent, 5000, worker, [mochiweb_socket_server]},
Processes = [Web1, Web2],
{ok, { {one_for_one, 10, 10}, Processes} }.
One other thing: judging from the name application_sup
appearing in your question, you may have run the webmachine ./scripts/new_webmachine.sh
and specified the application name as application
. If so, don't do this, since application
is the name of a key Erlang OTP module, and your code will clash with it and cause all kinds of problems.