Don't run warnings in a task.
[akkoma] / lib / pleroma / application.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Application do
6 use Application
7 import Supervisor.Spec
8
9 @name "Pleroma"
10 @version Mix.Project.config()[:version]
11 def name, do: @name
12 def version, do: @version
13 def named_version(), do: @name <> " " <> @version
14
15 def user_agent() do
16 info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
17 named_version() <> "; " <> info
18 end
19
20 # See http://elixir-lang.org/docs/stable/elixir/Application.html
21 # for more information on OTP Applications
22 def start(_type, _args) do
23 import Cachex.Spec
24
25 Pleroma.DeprecationWarnings.warn()
26
27 # Define workers and child supervisors to be supervised
28 children =
29 [
30 # Start the Ecto repository
31 supervisor(Pleroma.Repo, []),
32 worker(Pleroma.Emoji, []),
33 worker(Pleroma.Captcha, []),
34 worker(
35 Cachex,
36 [
37 :used_captcha_cache,
38 [
39 ttl_interval: :timer.seconds(Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid]))
40 ]
41 ],
42 id: :cachex_used_captcha_cache
43 ),
44 worker(
45 Cachex,
46 [
47 :user_cache,
48 [
49 default_ttl: 25000,
50 ttl_interval: 1000,
51 limit: 2500
52 ]
53 ],
54 id: :cachex_user
55 ),
56 worker(
57 Cachex,
58 [
59 :object_cache,
60 [
61 default_ttl: 25000,
62 ttl_interval: 1000,
63 limit: 2500
64 ]
65 ],
66 id: :cachex_object
67 ),
68 worker(
69 Cachex,
70 [
71 :rich_media_cache,
72 [
73 default_ttl: :timer.minutes(120),
74 limit: 5000
75 ]
76 ],
77 id: :cachex_rich_media
78 ),
79 worker(
80 Cachex,
81 [
82 :scrubber_cache,
83 [
84 limit: 2500
85 ]
86 ],
87 id: :cachex_scrubber
88 ),
89 worker(
90 Cachex,
91 [
92 :idempotency_cache,
93 [
94 expiration:
95 expiration(
96 default: :timer.seconds(6 * 60 * 60),
97 interval: :timer.seconds(60)
98 ),
99 limit: 2500
100 ]
101 ],
102 id: :cachex_idem
103 ),
104 worker(Pleroma.Web.Federator.RetryQueue, []),
105 worker(Pleroma.Web.Federator, []),
106 worker(Pleroma.Stats, []),
107 worker(Pleroma.Web.Push, [])
108 ] ++
109 streamer_child() ++
110 chat_child() ++
111 [
112 # Start the endpoint when the application starts
113 supervisor(Pleroma.Web.Endpoint, []),
114 worker(Pleroma.Gopher.Server, [])
115 ]
116
117 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
118 # for other strategies and supported options
119 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
120 Supervisor.start_link(children, opts)
121 end
122
123 if Mix.env() == :test do
124 defp streamer_child(), do: []
125 defp chat_child(), do: []
126 else
127 defp streamer_child() do
128 [worker(Pleroma.Web.Streamer, [])]
129 end
130
131 defp chat_child() do
132 if Pleroma.Config.get([:chat, :enabled]) do
133 [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
134 else
135 []
136 end
137 end
138 end
139 end