mysql_poolboy_sup.erl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. %% MySQL/OTP + Poolboy
  2. %% Copyright (C) 2015 Raoul Hess
  3. %%
  4. %% This file is part of MySQL/OTP + Poolboy.
  5. %%
  6. %% MySQL/OTP + Poolboy is free software: you can redistribute it and/or modify it under
  7. %% the terms of the GNU Lesser General Public License as published by the Free
  8. %% Software Foundation, either version 3 of the License, or (at your option)
  9. %% any later version.
  10. %%
  11. %% This program is distributed in the hope that it will be useful, but WITHOUT
  12. %% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. %% FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
  14. %% more details.
  15. %%
  16. %% You should have received a copy of the GNU Lesser General Public License
  17. %% along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. -module(mysql_poolboy_sup).
  19. -behaviour(supervisor).
  20. -export([start_link/0, init/1]).
  21. start_link() ->
  22. supervisor:start_link({local, ?MODULE}, ?MODULE, []).
  23. init([]) ->
  24. Pools = application:get_all_env(mysql_poolboy),
  25. Pools1 = proplists:delete(included_applications, Pools),
  26. PoolSpec = lists:map(
  27. fun ({PoolName, {PoolArgs, MysqlArgs}}) ->
  28. mysql_poolboy:child_spec(PoolName, PoolArgs, MysqlArgs)
  29. end,
  30. Pools1
  31. ),
  32. {ok, {{one_for_one, 10, 10}, PoolSpec}}.