Merge branch 'tests/apc2s-update_outbox' into 'develop'
[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.Config
9 alias Pleroma.Pool
10
11 def start_link(args) do
12 Supervisor.start_link(__MODULE__, args, name: __MODULE__)
13 end
14
15 def init(_) do
16 conns_child = %{
17 id: Pool.Connections,
18 start:
19 {Pool.Connections, :start_link, [{:gun_connections, Config.get([:connections_pool])}]}
20 }
21
22 Supervisor.init([conns_child | pools()], strategy: :one_for_one)
23 end
24
25 defp pools do
26 pools = Config.get(:pools)
27
28 pools =
29 if Config.get([Pleroma.Upload, :proxy_remote]) == false do
30 Keyword.delete(pools, :upload)
31 else
32 pools
33 end
34
35 for {pool_name, pool_opts} <- pools do
36 pool_opts
37 |> Keyword.put(:id, {Pool, pool_name})
38 |> Keyword.put(:name, pool_name)
39 |> Pool.child_spec()
40 end
41 end
42 end