X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fapplication.ex;h=6bda2e1d97f7396085c7b20d89aa10a99633d52a;hb=0f132b802dde7f217ecb07767e0d34e3edb517b7;hp=fcb1d65711c0d799e8635b9d90f7148a862608da;hpb=becf7dced6c051326f33dd201ac25d38af341b24;p=akkoma diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index fcb1d6571..6bda2e1d9 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -77,17 +77,31 @@ defmodule Pleroma.Application do ] ++ elasticsearch_children() ++ task_children(@mix_env) ++ - dont_run_in_test(@mix_env) ++ - shout_child(shout_enabled?()) + dont_run_in_test(@mix_env) # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html # for other strategies and supported options - opts = [strategy: :one_for_one, name: Pleroma.Supervisor] - result = Supervisor.start_link(children, opts) + # If we have a lot of caches, default max_restarts can cause test + # resets to fail. + # Go for the default 3 unless we're in test + max_restarts = + if @mix_env == :test do + 100 + else + 3 + end - set_postgres_server_version() + opts = [strategy: :one_for_one, name: Pleroma.Supervisor, max_restarts: max_restarts] - result + with {:ok, data} <- Supervisor.start_link(children, opts) do + set_postgres_server_version() + {:ok, data} + else + e -> + Logger.error("Failed to start!") + Logger.error("#{inspect(e)}") + e + end end defp set_postgres_server_version do @@ -163,11 +177,7 @@ defmodule Pleroma.Application do build_cachex("web_resp", limit: 2500), build_cachex("emoji_packs", expiration: emoji_packs_expiration(), limit: 10), build_cachex("failed_proxy_url", limit: 2500), - build_cachex("banned_urls", default_ttl: :timer.hours(24 * 30), limit: 5_000), - build_cachex("chat_message_id_idempotency_key", - expiration: chat_message_id_idempotency_key_expiration(), - limit: 500_000 - ) + build_cachex("banned_urls", default_ttl: :timer.hours(24 * 30), limit: 5_000) ] end @@ -177,9 +187,6 @@ defmodule Pleroma.Application do defp idempotency_expiration, do: expiration(default: :timer.seconds(6 * 60 * 60), interval: :timer.seconds(60)) - defp chat_message_id_idempotency_key_expiration, - do: expiration(default: :timer.minutes(2), interval: :timer.seconds(60)) - defp seconds_valid_interval, do: :timer.seconds(Config.get!([Pleroma.Captcha, :seconds_valid])) @@ -191,8 +198,6 @@ defmodule Pleroma.Application do type: :worker } - defp shout_enabled?, do: Config.get([:shout, :enabled]) - defp dont_run_in_test(env) when env in [:test, :benchmark], do: [] defp dont_run_in_test(_) do @@ -212,15 +217,6 @@ defmodule Pleroma.Application do ] end - defp shout_child(true) do - [ - Pleroma.Web.ShoutChannel.ShoutChannelState, - {Phoenix.PubSub, [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2]} - ] - end - - defp shout_child(_), do: [] - defp task_children(:test) do [ %{