tests changes
[akkoma] / lib / pleroma / pool / supervisor.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Pool.Supervisor do
6 use Supervisor
7
8 alias Pleroma.Pool
9
10 def start_link(args) do
11 Supervisor.start_link(__MODULE__, args, name: __MODULE__)
12 end
13
14 def init(_) do
15 children =
16 [
17 %{
18 id: Pool.Connections,
19 start:
20 {Pool.Connections, :start_link,
21 [{:gun_connections, Pleroma.Config.get([:connections_pool])}]}
22 }
23 ] ++ pools()
24
25 Supervisor.init(children, strategy: :one_for_one)
26 end
27
28 defp pools do
29 for {pool_name, pool_opts} <- Pleroma.Config.get([:pools]) do
30 pool_opts
31 |> Keyword.put(:id, {Pool, pool_name})
32 |> Keyword.put(:name, pool_name)
33 |> Pool.child_spec()
34 end
35 end
36 end