PageRenderTime 29ms CodeModel.GetById 14ms app.highlight 10ms RepoModel.GetById 2ms app.codeStats 0ms

/deps/webmachine/demo/src/webmachine_demo_sup.erl

https://code.google.com/p/zotonic/
Erlang | 42 lines | 25 code | 8 blank | 9 comment | 0 complexity | 883a0c91ed5381a3046543170ac59f67 MD5 | raw file
 1%% @author Justin Sheehy <justin@basho.com>
 2%% @author Andy Gross <andy@basho.com>
 3%% @copyright 2007-2008 Basho Technologies
 4
 5%% @doc Supervisor for the webmachine_demo application.
 6
 7-module(webmachine_demo_sup).
 8-author('Justin Sheehy <justin@basho.com>').
 9-author('Andy Gross <andy@basho.com>').
10
11-behaviour(supervisor).
12
13%% External exports
14-export([start_link/0]).
15
16%% supervisor callbacks
17-export([init/1]).
18
19%% @spec start_link() -> ServerRet
20%% @doc API for starting the supervisor.
21start_link() ->
22    supervisor:start_link({local, ?MODULE}, ?MODULE, []).
23
24dispatch_map() ->
25    [{["demo", '*'], webmachine_demo_resource, []},
26     {["fs", '*'], demo_fs_resource, [{root, "/tmp/fs"}]}
27    ].
28
29%% @doc supervisor callback.
30init([]) ->
31    Ip = case os:getenv("WEBMACHINE_IP") of false -> "0.0.0.0"; Any -> Any end,
32    WebConfig = [
33		 {ip, Ip},
34                 {backlog, 1000},
35		 {port, 8000},
36                 {log_dir, "priv/log"},
37		 {dispatch, dispatch_map()}],
38    Web = {webmachine_mochiweb,
39	   {webmachine_mochiweb, start, [WebConfig]},
40	   permanent, 5000, worker, dynamic},
41    Processes = [Web],
42    {ok, {{one_for_one, 10, 10}, Processes}}.