From 029aaf3d744184737666b1e553ed92d7708f1fee Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sat, 20 Jan 2024 18:14:27 -0500 Subject: [PATCH] Use config to control max_restarts --- config/config.exs | 3 +++ config/test.exs | 2 ++ lib/pleroma/application.ex | 7 +------ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/config.exs b/config/config.exs index d8f9eb22e..27fbabc73 100644 --- a/config/config.exs +++ b/config/config.exs @@ -904,6 +904,9 @@ config :pleroma, Pleroma.Search.Meilisearch, private_key: nil, initial_indexing_chunk_size: 100_000 +config :pleroma, Pleroma.Application, + max_restarts: 3 + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/config/test.exs b/config/test.exs index 60cdacb0e..11e115b99 100644 --- a/config/test.exs +++ b/config/test.exs @@ -162,6 +162,8 @@ peer_module = config :pleroma, Pleroma.Cluster, peer_module: peer_module +config :pleroma, Pleroma.Application, max_restarts: 100 + if File.exists?("./config/test.secret.exs") do import_config "test.secret.exs" else diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 8fa6f3fae..a01a13b18 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -116,12 +116,7 @@ defmodule Pleroma.Application do # 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 + max_restarts = Application.get_env(:pleroma, __MODULE__)[:max_restarts] opts = [strategy: :one_for_one, name: Pleroma.Supervisor, max_restarts: max_restarts] result = Supervisor.start_link(children, opts)