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
9 @name Mix.Project.config()[:name]
10 @version Mix.Project.config()[:version]
11 @repository Mix.Project.config()[:source_url]
13 def version, do: @version
14 def named_version(), do: @name <> " " <> @version
15 def repository, do: @repository
18 info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
19 named_version() <> "; " <> info
22 # See http://elixir-lang.org/docs/stable/elixir/Application.html
23 # for more information on OTP Applications
24 def start(_type, _args) do
27 Pleroma.Config.DeprecationWarnings.warn()
29 # Define workers and child supervisors to be supervised
32 # Start the Ecto repository
33 supervisor(Pleroma.Repo, []),
34 worker(Pleroma.Emoji, []),
35 worker(Pleroma.Captcha, []),
41 ttl_interval: :timer.seconds(Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid]))
44 id: :cachex_used_captcha_cache
75 default_ttl: :timer.minutes(120),
79 id: :cachex_rich_media
98 default: :timer.seconds(6 * 60 * 60),
99 interval: :timer.seconds(60)
106 worker(Pleroma.FlakeId, [])
108 hackney_pool_children() ++
110 worker(Pleroma.Web.Federator.RetryQueue, []),
111 worker(Pleroma.Stats, []),
112 worker(Pleroma.Web.Push, []),
113 worker(Pleroma.Jobs, []),
114 worker(Task, [&Pleroma.Web.Federator.init/0], restart: :temporary)
119 # Start the endpoint when the application starts
120 supervisor(Pleroma.Web.Endpoint, []),
121 worker(Pleroma.Gopher.Server, [])
124 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
125 # for other strategies and supported options
126 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
127 Supervisor.start_link(children, opts)
130 def enabled_hackney_pools() do
132 if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Hackney do
137 if Pleroma.Config.get([Pleroma.Uploader, :proxy_remote]) do
144 if Mix.env() == :test do
145 defp streamer_child(), do: []
146 defp chat_child(), do: []
148 defp streamer_child() do
149 [worker(Pleroma.Web.Streamer, [])]
153 if Pleroma.Config.get([:chat, :enabled]) do
154 [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
161 defp hackney_pool_children() do
162 for pool <- enabled_hackney_pools() do
163 options = Pleroma.Config.get([:hackney_pools, pool])
164 :hackney_pool.child_spec(pool, options)