You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB

пре 10 година
пре 15 година
пре 10 година
пре 15 година
пре 10 година
пре 15 година
пре 10 година
  1. %%%-------------------------------------------------------------------
  2. %% @copyright {{copyright_holder}} ({{copyright_year}})
  3. %% @author {{author_name}} <{{author_email}}>
  4. %% @doc {{appid}} OTP application callback module.
  5. %% @end
  6. %%%-------------------------------------------------------------------
  7. -module({{appid}}_app).
  8. -behaviour(application).
  9. -define(APP, {{appid}}).
  10. %% Application callbacks
  11. -export([start/2, stop/1]).
  12. -export([config/0, config/1, config/2,
  13. start/0]).
  14. %%%===================================================================
  15. %%% Convenience Functions
  16. %%%===================================================================
  17. start() ->
  18. application:ensure_all_started(?APP, permanent).
  19. config(Key, Default) ->
  20. case application:get_env(?APP, Key) of
  21. undefined -> Default;
  22. {ok, Val} -> Val
  23. end.
  24. config(Key) ->
  25. case application:get_env(?APP, Key) of
  26. undefined -> erlang:error({missing_config, Key});
  27. {ok, Val} -> Val
  28. end.
  29. config() ->
  30. application:get_all_env(?APP).
  31. %% ===================================================================
  32. %% Application callbacks
  33. %% ===================================================================
  34. start(_StartType, _StartArgs) ->
  35. {{appid}}_sup:start_link().
  36. stop(_State) ->
  37. ok.
  38. %%%===================================================================
  39. %%% Internal functions
  40. %%%===================================================================