2020-02-11 00:12:57 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-03 16:16:24 -07:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2020-02-11 00:12:57 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Pool.Supervisor do
|
|
|
|
use Supervisor
|
|
|
|
|
2020-03-07 02:24:39 -07:00
|
|
|
alias Pleroma.Config
|
2020-02-11 00:12:57 -07:00
|
|
|
alias Pleroma.Pool
|
|
|
|
|
|
|
|
def start_link(args) do
|
|
|
|
Supervisor.start_link(__MODULE__, args, name: __MODULE__)
|
|
|
|
end
|
|
|
|
|
|
|
|
def init(_) do
|
|
|
|
children =
|
|
|
|
[
|
|
|
|
%{
|
|
|
|
id: Pool.Connections,
|
|
|
|
start:
|
2020-03-07 02:24:39 -07:00
|
|
|
{Pool.Connections, :start_link, [{:gun_connections, Config.get([:connections_pool])}]}
|
2020-02-11 00:12:57 -07:00
|
|
|
}
|
|
|
|
] ++ pools()
|
|
|
|
|
|
|
|
Supervisor.init(children, strategy: :one_for_one)
|
|
|
|
end
|
|
|
|
|
|
|
|
defp pools do
|
2020-03-07 02:24:39 -07:00
|
|
|
pools = Config.get(:pools)
|
|
|
|
|
|
|
|
pools =
|
|
|
|
if Config.get([Pleroma.Upload, :proxy_remote]) == false do
|
|
|
|
Keyword.delete(pools, :upload)
|
|
|
|
else
|
|
|
|
pools
|
|
|
|
end
|
|
|
|
|
|
|
|
for {pool_name, pool_opts} <- pools do
|
2020-02-11 00:12:57 -07:00
|
|
|
pool_opts
|
|
|
|
|> Keyword.put(:id, {Pool, pool_name})
|
|
|
|
|> Keyword.put(:name, pool_name)
|
|
|
|
|> Pool.child_spec()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|