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()
30 # Define workers and child supervisors to be supervised
33 # Start the Ecto repository
34 supervisor(Pleroma.Repo, []),
35 worker(Pleroma.Emoji, []),
36 worker(Pleroma.Captcha, []),
42 ttl_interval: :timer.seconds(Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid]))
45 id: :cachex_used_captcha_cache
76 default_ttl: :timer.minutes(120),
80 id: :cachex_rich_media
99 default: :timer.seconds(6 * 60 * 60),
100 interval: :timer.seconds(60)
107 worker(Pleroma.FlakeId, []),
108 worker(Pleroma.ScheduledActivityWorker, [])
110 hackney_pool_children() ++
112 worker(Pleroma.Web.Federator.RetryQueue, []),
113 worker(Pleroma.Stats, []),
114 worker(Task, [&Pleroma.Web.Push.init/0], restart: :temporary, id: :web_push_init),
115 worker(Task, [&Pleroma.Web.Federator.init/0], restart: :temporary, id: :federator_init)
120 # Start the endpoint when the application starts
121 supervisor(Pleroma.Web.Endpoint, []),
122 worker(Pleroma.Gopher.Server, [])
125 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
126 # for other strategies and supported options
127 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
128 Supervisor.start_link(children, opts)
131 defp setup_instrumenters do
132 require Prometheus.Registry
137 [:pleroma, :repo, :query],
138 &Pleroma.Repo.Instrumenter.handle_event/4,
142 Prometheus.Registry.register_collector(:prometheus_process_collector)
143 Pleroma.Web.Endpoint.MetricsExporter.setup()
144 Pleroma.Web.Endpoint.PipelineInstrumenter.setup()
145 Pleroma.Web.Endpoint.Instrumenter.setup()
146 Pleroma.Repo.Instrumenter.setup()
149 def enabled_hackney_pools do
151 if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Hackney do
156 if Pleroma.Config.get([Pleroma.Uploader, :proxy_remote]) do
163 if Mix.env() == :test do
164 defp streamer_child, do: []
165 defp chat_child, do: []
167 defp streamer_child do
168 [worker(Pleroma.Web.Streamer, [])]
172 if Pleroma.Config.get([:chat, :enabled]) do
173 [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
180 defp hackney_pool_children do
181 for pool <- enabled_hackney_pools() do
182 options = Pleroma.Config.get([:hackney_pools, pool])
183 :hackney_pool.child_spec(pool, options)