diff options
author | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-08-13 12:39:36 +0300 |
---|---|---|
committer | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-09-24 10:12:06 +0300 |
commit | c169838bd989c1945a4261f5ce74fde8064c6aa3 (patch) | |
tree | 75be3b363ab6374bc8fae4df8b3bb9d1aa23e0b2 | |
parent | 9b74780665140d1fccf3d2216cf975404dfac4cc (diff) | |
download | pleroma-c169838bd989c1945a4261f5ce74fde8064c6aa3.tar.gz |
start Oban in mix tasks when needed
-rw-r--r-- | lib/mix/pleroma.ex | 17 | ||||
-rw-r--r-- | lib/mix/tasks/pleroma/relay.ex | 4 | ||||
-rw-r--r-- | lib/mix/tasks/pleroma/user.ex | 2 |
3 files changed, 13 insertions, 10 deletions
diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex index 6c2688b3c..0bebe4d54 100644 --- a/lib/mix/pleroma.ex +++ b/lib/mix/pleroma.ex @@ -13,9 +13,11 @@ defmodule Mix.Pleroma do :swoosh, :timex ] + @cachex_children ["object", "user", "scrubber"] + @doc "Common functions to be reused in mix tasks" - def start_pleroma do + def start_pleroma(additional_childs \\ []) do Pleroma.Config.Holder.save_default() Pleroma.Config.Oban.warn() Application.put_env(:phoenix, :serve_endpoints, false, persistent: true) @@ -35,12 +37,13 @@ defmodule Mix.Pleroma do Enum.each(apps, &Application.ensure_all_started/1) - children = [ - Pleroma.Repo, - Supervisor.child_spec({Task, &Pleroma.Config.Environment.load_and_update/0}, - id: :update_env - ) - ] + children = + [ + Pleroma.Repo, + Supervisor.child_spec({Task, &Pleroma.Config.Environment.load_and_update/0}, + id: :update_env + ) + ] ++ additional_childs children = if adapter == Tesla.Adapter.Gun do diff --git a/lib/mix/tasks/pleroma/relay.ex b/lib/mix/tasks/pleroma/relay.ex index a6d8d6c1c..8ad32a5e5 100644 --- a/lib/mix/tasks/pleroma/relay.ex +++ b/lib/mix/tasks/pleroma/relay.ex @@ -11,7 +11,7 @@ defmodule Mix.Tasks.Pleroma.Relay do @moduledoc File.read!("docs/administration/CLI_tasks/relay.md") def run(["follow", target]) do - start_pleroma() + start_pleroma([{Oban, Pleroma.Config.get(Oban)}]) with {:ok, _activity} <- Relay.follow(target) do # put this task to sleep to allow the genserver to push out the messages @@ -22,7 +22,7 @@ defmodule Mix.Tasks.Pleroma.Relay do end def run(["unfollow", target]) do - start_pleroma() + start_pleroma([{Oban, Pleroma.Config.get(Oban)}]) with {:ok, _activity} <- Relay.unfollow(target) do # put this task to sleep to allow the genserver to push out the messages diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index b20c49d89..562d1cadb 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -96,7 +96,7 @@ defmodule Mix.Tasks.Pleroma.User do end def run(["rm", nickname]) do - start_pleroma() + start_pleroma([{Oban, Pleroma.Config.get(Oban)}]) with %User{local: true} = user <- User.get_cached_by_nickname(nickname), {:ok, delete_data, _} <- Builder.delete(user, user.ap_id), |