Make backup timeout configurable

This commit is contained in:
Mark Felder 2024-07-22 14:00:54 -04:00
parent e5cbbaf3f0
commit 187897874b
4 changed files with 12 additions and 11 deletions

View File

@ -908,8 +908,8 @@ config :pleroma, Pleroma.User.Backup,
purge_after_days: 30, purge_after_days: 30,
limit_days: 7, limit_days: 7,
dir: nil, dir: nil,
process_wait_time: 30_000, process_chunk_size: 100,
process_chunk_size: 100 timeout: :timer.minutes(30)
config :pleroma, ConcurrentLimiter, [ config :pleroma, ConcurrentLimiter, [
{Pleroma.Search, [max_running: 30, max_waiting: 50]} {Pleroma.Search, [max_running: 30, max_waiting: 50]}

View File

@ -3355,20 +3355,19 @@ config :pleroma, :config_description, [
description: "Limit user to export not more often than once per N days", description: "Limit user to export not more often than once per N days",
suggestions: [7] suggestions: [7]
}, },
%{
key: :process_wait_time,
type: :integer,
label: "Process Wait Time",
description:
"The amount of time to wait for backup to report progress, in milliseconds. If no progress is received from the backup job for that much time, terminate it and deem it failed.",
suggestions: [30_000]
},
%{ %{
key: :process_chunk_size, key: :process_chunk_size,
type: :integer, type: :integer,
label: "Process Chunk Size", label: "Process Chunk Size",
description: "The number of activities to fetch in the backup job for each chunk.", description: "The number of activities to fetch in the backup job for each chunk.",
suggestions: [100] suggestions: [100]
},
%{
key: :timeout,
type: :integer,
label: "Timeout",
description: "The amount of time to wait for backup to complete in seconds.",
suggestions: [1_800]
} }
] ]
}, },

View File

@ -1171,6 +1171,7 @@ Control favicons for instances.
3. the directory named by the TMP environment variable 3. the directory named by the TMP environment variable
4. C:\TMP on Windows or /tmp on Unix-like operating systems 4. C:\TMP on Windows or /tmp on Unix-like operating systems
5. as a last resort, the current working directory 5. as a last resort, the current working directory
* `:timeout` an integer representing seconds
## Frontend management ## Frontend management

View File

@ -6,6 +6,7 @@ defmodule Pleroma.Workers.BackupWorker do
use Oban.Worker, queue: :slow, max_attempts: 1 use Oban.Worker, queue: :slow, max_attempts: 1
alias Oban.Job alias Oban.Job
alias Pleroma.Config.Getting, as: Config
alias Pleroma.User.Backup alias Pleroma.User.Backup
@impl Oban.Worker @impl Oban.Worker
@ -32,7 +33,7 @@ defmodule Pleroma.Workers.BackupWorker do
end end
@impl Oban.Worker @impl Oban.Worker
def timeout(_job), do: :timer.minutes(30) def timeout(_job), do: Config.get([Backup, :timeout], :timer.minutes(30))
defp has_email?(user) do defp has_email?(user) do
not is_nil(user.email) and user.email != "" not is_nil(user.email) and user.email != ""