/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. %% @doc Supervisor for the webmachine_demo application.
  5. -module(webmachine_demo_sup).
  6. -author('Justin Sheehy <justin@basho.com>').
  7. -author('Andy Gross <andy@basho.com>').
  8. -behaviour(supervisor).
  9. %% External exports
  10. -export([start_link/0]).
  11. %% supervisor callbacks
  12. -export([init/1]).
  13. %% @spec start_link() -> ServerRet
  14. %% @doc API for starting the supervisor.
  15. start_link() ->
  16. supervisor:start_link({local, ?MODULE}, ?MODULE, []).
  17. dispatch_map() ->
  18. [{["demo", '*'], webmachine_demo_resource, []},
  19. {["fs", '*'], demo_fs_resource, [{root, "/tmp/fs"}]}
  20. ].
  21. %% @doc supervisor callback.
  22. init([]) ->
  23. Ip = case os:getenv("WEBMACHINE_IP") of false -> "0.0.0.0"; Any -> Any end,
  24. WebConfig = [
  25. {ip, Ip},
  26. {backlog, 1000},
  27. {port, 8000},
  28. {log_dir, "priv/log"},
  29. {dispatch, dispatch_map()}],
  30. Web = {webmachine_mochiweb,
  31. {webmachine_mochiweb, start, [WebConfig]},
  32. permanent, 5000, worker, dynamic},
  33. Processes = [Web],
  34. {ok, {{one_for_one, 10, 10}, Processes}}.