X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fapplication.ex;h=9e262235eef83c86b2426924508699ac7c7dc1ef;hb=793fc77b160ae2bcaded23d22d7606c2ab499f0a;hp=7c4cd9626d04c30fd06d2bb54fedda9d99951603;hpb=24ce3249736c96686c00a10abe47659579535259;p=akkoma
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index 7c4cd9626..9e262235e 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Application do
@@ -57,6 +57,7 @@ defmodule Pleroma.Application do
setup_instrumenters()
load_custom_modules()
Pleroma.Docs.JSON.compile()
+ limiters_setup()
adapter = Application.get_env(:tesla, :adapter)
@@ -109,7 +110,28 @@ defmodule Pleroma.Application do
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
- Supervisor.start_link(children, opts)
+ result = Supervisor.start_link(children, opts)
+
+ set_postgres_server_version()
+
+ result
+ end
+
+ defp set_postgres_server_version do
+ version =
+ with %{rows: [[version]]} <- Ecto.Adapters.SQL.query!(Pleroma.Repo, "show server_version"),
+ {num, _} <- Float.parse(version) do
+ num
+ else
+ e ->
+ Logger.warn(
+ "Could not get the postgres version: #{inspect(e)}.\nSetting the default value of 9.6"
+ )
+
+ 9.6
+ end
+
+ :persistent_term.put({Pleroma.Repo, :postgres_version}, version)
end
def load_custom_modules do
@@ -207,8 +229,7 @@ defmodule Pleroma.Application do
name: Pleroma.Web.Streamer.registry(),
keys: :duplicate,
partitions: System.schedulers_online()
- ]},
- Pleroma.Web.FedSockets.Supervisor
+ ]}
]
end
@@ -273,4 +294,19 @@ defmodule Pleroma.Application do
end
defp http_children(_, _), do: []
+
+ @spec limiters_setup() :: :ok
+ def limiters_setup do
+ config = Config.get(ConcurrentLimiter, [])
+
+ [Pleroma.Web.RichMedia.Helpers, Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy]
+ |> Enum.each(fn module ->
+ mod_config = Keyword.get(config, module, [])
+
+ max_running = Keyword.get(mod_config, :max_running, 5)
+ max_waiting = Keyword.get(mod_config, :max_waiting, 5)
+
+ ConcurrentLimiter.new(module, max_running, max_waiting)
+ end)
+ end
end