emqx_kernel_sup.erl 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. %%--------------------------------------------------------------------
  2. %% Copyright (c) 2018-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
  3. %%
  4. %% Licensed under the Apache License, Version 2.0 (the "License");
  5. %% you may not use this file except in compliance with the License.
  6. %% You may obtain a copy of the License at
  7. %%
  8. %% http://www.apache.org/licenses/LICENSE-2.0
  9. %%
  10. %% Unless required by applicable law or agreed to in writing, software
  11. %% distributed under the License is distributed on an "AS IS" BASIS,
  12. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. %% See the License for the specific language governing permissions and
  14. %% limitations under the License.
  15. %%--------------------------------------------------------------------
  16. -module(emqx_kernel_sup).
  17. -behaviour(supervisor).
  18. -export([start_link/0]).
  19. -export([init/1]).
  20. start_link() ->
  21. supervisor:start_link({local, ?MODULE}, ?MODULE, []).
  22. init([]) ->
  23. {ok, {
  24. {one_for_one, 10, 100},
  25. %% always start emqx_config_handler first to load the emqx.conf to emqx_config
  26. [
  27. child_spec(emqx_config_handler, worker),
  28. child_spec(emqx_pool_sup, supervisor, [
  29. emqx:get_config([node, generic_pool_size], emqx_vm:schedulers())
  30. ]),
  31. child_spec(emqx_hooks, worker),
  32. child_spec(emqx_stats, worker),
  33. child_spec(emqx_metrics, worker),
  34. child_spec(emqx_authn_authz_metrics_sup, supervisor),
  35. child_spec(emqx_ocsp_cache, worker),
  36. child_spec(emqx_crl_cache, worker),
  37. child_spec(emqx_tls_lib_sup, supervisor),
  38. child_spec(emqx_log_throttler, worker)
  39. ]
  40. }}.
  41. child_spec(M, Type) ->
  42. child_spec(M, Type, []).
  43. child_spec(M, worker, Args) ->
  44. #{
  45. id => M,
  46. start => {M, start_link, Args},
  47. restart => permanent,
  48. shutdown => 5000,
  49. type => worker,
  50. modules => [M]
  51. };
  52. child_spec(M, supervisor, Args) ->
  53. #{
  54. id => M,
  55. start => {M, start_link, Args},
  56. restart => permanent,
  57. shutdown => infinity,
  58. type => supervisor,
  59. modules => [M]
  60. }.