fix warnings
[akkoma] / lib / pleroma / application.ex
1 defmodule Pleroma.Application do
2 use Application
3 import Supervisor.Spec
4
5 @name "Pleroma"
6 @version Mix.Project.config()[:version]
7 def name, do: @name
8 def version, do: @version
9 def named_version(), do: @name <> " " <> @version
10
11 def user_agent() do
12 info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
13 named_version() <> "; " <> info
14 end
15
16 # See http://elixir-lang.org/docs/stable/elixir/Application.html
17 # for more information on OTP Applications
18 def start(_type, _args) do
19 import Cachex.Spec
20
21 # Define workers and child supervisors to be supervised
22 children =
23 [
24 # Start the Ecto repository
25 supervisor(Pleroma.Repo, []),
26 worker(Pleroma.Emoji, []),
27 worker(
28 Cachex,
29 [
30 :user_cache,
31 [
32 default_ttl: 25000,
33 ttl_interval: 1000,
34 limit: 2500
35 ]
36 ],
37 id: :cachex_user
38 ),
39 worker(
40 Cachex,
41 [
42 :object_cache,
43 [
44 default_ttl: 25000,
45 ttl_interval: 1000,
46 limit: 2500
47 ]
48 ],
49 id: :cachex_object
50 ),
51 worker(
52 Cachex,
53 [
54 :idempotency_cache,
55 [
56 expiration:
57 expiration(
58 default: :timer.seconds(6 * 60 * 60),
59 interval: :timer.seconds(60)
60 ),
61 limit: 2500
62 ]
63 ],
64 id: :cachex_idem
65 ),
66 worker(Pleroma.Web.Federator.RetryQueue, []),
67 worker(Pleroma.Web.Federator, []),
68 worker(Pleroma.Stats, []),
69 worker(Pleroma.Web.Push, [])
70 ] ++
71 streamer_child() ++
72 chat_child() ++
73 [
74 # Start the endpoint when the application starts
75 supervisor(Pleroma.Web.Endpoint, []),
76 worker(Pleroma.Gopher.Server, [])
77 ]
78
79 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
80 # for other strategies and supported options
81 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
82 Supervisor.start_link(children, opts)
83 end
84
85 if Mix.env() == :test do
86 defp streamer_child(), do: []
87 defp chat_child(), do: []
88 else
89 defp streamer_child() do
90 [worker(Pleroma.Web.Streamer, [])]
91 end
92
93 defp chat_child() do
94 if Pleroma.Config.get([:chat, :enabled]) do
95 [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
96 else
97 []
98 end
99 end
100 end
101 end