1234567891011121314151617181920212223242526272829303132333435 |
- -module(sample).
- -behaviour(supervisor).
- -behaviour(application).
- -export([init/1, start/2, stop/1, main/1]).
- -export([
- log_modules/0
- ]).
- main(A) -> mad_repl:sh(A).
- start(_,_) -> supervisor:start_link({local,sample},sample,[]).
- stop(_) -> ok.
- init([]) -> case cowboy:start_http(http,3,port(),env()) of
- {ok, _} -> ok;
- {error,_} -> halt(abort,[]) end, sup().
- sup() -> { ok, { { one_for_one, 5, 100 }, [] } }.
- env() -> [ { env, [ { dispatch, points() } ] } ].
- static() -> { dir, "apps/sample/priv/static", mime() }.
- n4u() -> { dir, "deps/n4u/priv", mime() }.
- mime() -> [ { mimetypes, cow_mimetypes, all } ].
- port() -> [ { port, wf:config(n4u,port,8001) } ].
- points() -> cowboy_router:compile([{'_', [
- { "/static/[...]", n2o_static, static() },
- { "/n4u/[...]", n2o_static, n4u() },
- { "/ws/[...]", n2o_stream, [] },
- { '_', n2o_cowboy, [] }]}]).
- log_modules() -> [n2o_client,n2o_nitrogen,n2o_stream,wf_convert].
|