Advertisement
Guest User

Untitled

a guest
Apr 1st, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. -module(review).
  2. -behaviour(supervisor).
  3. -behaviour(application).
  4. -export([init/1, start/2, stop/1, main/1]).
  5. -include_lib("kvs/include/user.hrl").
  6.  
  7. main(A) -> mad:main(A).
  8.  
  9. start() -> start(normal,[]).
  10.  
  11.  
  12. start(_,_) -> supervisor:start_link({local,review},review,[]).
  13. stop(_) -> ok.
  14.  
  15. -define(USERS, [#user{id="maxim",email="maxim@synrc.com"},
  16. #user{id="doxtop",email="doxtop@synrc.com"},
  17. #user{id="roman",email="roman@github.com"}]).
  18.  
  19. init([]) -> users:init(), syn:init(),
  20. users:populate(?USERS),
  21. kvs:join(),
  22. Start RIAK POOL
  23. case riaki:init() of
  24. ok -> io:format("RIAK POOL Started... \n\r");
  25. error -> io:format("RIAK POOL ERR...") end,
  26. {ok, {{one_for_one, 5, 10}, [spec()]}}.
  27.  
  28. spec() -> ranch:child_spec(http, 100, ranch_tcp, port(), cowboy_protocol, env()).
  29. env() -> [ { env, [ { dispatch, points() } ] } ].
  30. static() -> { dir, "apps/review/priv/static", mime() }.
  31. n2o() -> { dir, "deps/n2o/priv", mime() }.
  32. mime() -> [ { mimetypes, cow_mimetypes, all } ].
  33. port() -> [ { port, wf:config(n2o,port,8000) } ].
  34. points() -> cowboy_router:compile([{'_', [
  35.  
  36. {"/static/[...]", n2o_static, static()},
  37. {"/n2o/[...]", n2o_static, n2o()},
  38. {"/multipart/[...]", n2o_multipart, []},
  39. {"/rest/:resource", rest_cowboy, []},
  40. {"/rest/:resource/:id", rest_cowboy, []},
  41. {"/ws/[...]", n2o_stream, []},
  42. {'_', n2o_cowboy, []} ]}]).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement