1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Application do
10 @version Mix.Project.config()[:version]
12 def version, do: @version
13 def named_version(), do: @name <> " " <> @version
16 info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
17 named_version() <> "; " <> info
20 # See http://elixir-lang.org/docs/stable/elixir/Application.html
21 # for more information on OTP Applications
22 def start(_type, _args) do
25 Pleroma.Config.DeprecationWarnings.warn()
27 # Define workers and child supervisors to be supervised
30 # Start the Ecto repository
31 supervisor(Pleroma.Repo, []),
32 worker(Pleroma.Emoji, []),
33 worker(Pleroma.Captcha, []),
39 ttl_interval: :timer.seconds(Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid]))
42 id: :cachex_used_captcha_cache
73 default_ttl: :timer.minutes(120),
77 id: :cachex_rich_media
96 default: :timer.seconds(6 * 60 * 60),
97 interval: :timer.seconds(60)
104 worker(Pleroma.FlakeId, [])
106 hackney_pool_children() ++
108 worker(Pleroma.Web.Federator.RetryQueue, []),
109 worker(Pleroma.Web.Federator, []),
110 worker(Pleroma.Stats, []),
111 worker(Pleroma.Web.Push, [])
116 # Start the endpoint when the application starts
117 supervisor(Pleroma.Web.Endpoint, []),
118 worker(Pleroma.Gopher.Server, [])
121 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
122 # for other strategies and supported options
123 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
124 Supervisor.start_link(children, opts)
127 def enabled_hackney_pools() do
129 if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Hackney do
134 if Pleroma.Config.get([Pleroma.Uploader, :proxy_remote]) do
141 if Mix.env() == :test do
142 defp streamer_child(), do: []
143 defp chat_child(), do: []
145 defp streamer_child() do
146 [worker(Pleroma.Web.Streamer, [])]
150 if Pleroma.Config.get([:chat, :enabled]) do
151 [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
158 defp hackney_pool_children() do
159 for pool <- enabled_hackney_pools() do
160 options = Pleroma.Config.get([:hackney_pools, pool])
161 :hackney_pool.child_spec(pool, options)