Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

55 строки
1.5 KiB

10 лет назад
10 лет назад
10 лет назад
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. %%%===================================================================