diff options
| author | lain <lain@soykaf.club> | 2020-08-28 12:17:19 +0000 |
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-08-28 12:17:19 +0000 |
| commit | 73dd5bdb7dcdf804bdbabcf632671d4de5042ebc (patch) | |
| tree | efcb0b8e68f86d067de98a23f40a24c7dab79d2f /lib/mix/pleroma.ex | |
| parent | f891e2b2f1d1daa122b9856e4b660be394d31e34 (diff) | |
| parent | b141e35d641e733dffe7bd6a45a5bbcafe586c56 (diff) | |
| download | pleroma-73dd5bdb7dcdf804bdbabcf632671d4de5042ebc.tar.gz pleroma-73dd5bdb7dcdf804bdbabcf632671d4de5042ebc.zip | |
Merge branch 'release/2.1.0' into 'stable'
Release/2.1.0
See merge request pleroma/pleroma!2927
Diffstat (limited to 'lib/mix/pleroma.ex')
| -rw-r--r-- | lib/mix/pleroma.ex | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex index 3ad6edbfb..fe9b0d16c 100644 --- a/lib/mix/pleroma.ex +++ b/lib/mix/pleroma.ex @@ -3,15 +3,53 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Mix.Pleroma do + @apps [ + :restarter, + :ecto, + :ecto_sql, + :postgrex, + :db_connection, + :cachex, + :flake_id, + :swoosh, + :timex + ] + @cachex_children ["object", "user", "scrubber"] @doc "Common functions to be reused in mix tasks" def start_pleroma do + Pleroma.Config.Holder.save_default() Application.put_env(:phoenix, :serve_endpoints, false, persistent: true) if Pleroma.Config.get(:env) != :test do Application.put_env(:logger, :console, level: :debug) end - {:ok, _} = Application.ensure_all_started(:pleroma) + adapter = Application.get_env(:tesla, :adapter) + + apps = + if adapter == Tesla.Adapter.Gun do + [:gun | @apps] + else + [:hackney | @apps] + end + + Enum.each(apps, &Application.ensure_all_started/1) + + children = + [ + Pleroma.Repo, + {Pleroma.Config.TransferTask, false}, + Pleroma.Web.Endpoint, + {Oban, Pleroma.Config.get(Oban)} + ] ++ + http_children(adapter) + + cachex_children = Enum.map(@cachex_children, &Pleroma.Application.build_cachex(&1, [])) + + Supervisor.start_link(children ++ cachex_children, + strategy: :one_for_one, + name: Pleroma.Supervisor + ) if Pleroma.Config.get(:env) not in [:test, :benchmark] do pleroma_rebooted?() @@ -82,4 +120,11 @@ defmodule Mix.Pleroma do def escape_sh_path(path) do ~S(') <> String.replace(path, ~S('), ~S(\')) <> ~S(') end + + defp http_children(Tesla.Adapter.Gun) do + Pleroma.Gun.ConnectionPool.children() ++ + [{Task, &Pleroma.HTTP.AdapterHelper.Gun.limiter_setup/0}] + end + + defp http_children(_), do: [] end |
