Remove the debugging IO.inspect
[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(Pleroma.Captcha, []),
28 worker(
29 Cachex,
30 [
31 :used_captcha_cache,
32 [
33 ttl_interval: :timer.seconds(Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid]))
34 ]
35 ],
36 id: :cachex_used_captcha_cache
37 ),
38 worker(
39 Cachex,
40 [
41 :user_cache,
42 [
43 default_ttl: 25000,
44 ttl_interval: 1000,
45 limit: 2500
46 ]
47 ],
48 id: :cachex_user
49 ),
50 worker(
51 Cachex,
52 [
53 :object_cache,
54 [
55 default_ttl: 25000,
56 ttl_interval: 1000,
57 limit: 2500
58 ]
59 ],
60 id: :cachex_object
61 ),
62 worker(
63 Cachex,
64 [
65 :idempotency_cache,
66 [
67 expiration:
68 expiration(
69 default: :timer.seconds(6 * 60 * 60),
70 interval: :timer.seconds(60)
71 ),
72 limit: 2500
73 ]
74 ],
75 id: :cachex_idem
76 ),
77 worker(Pleroma.Web.Federator.RetryQueue, []),
78 worker(Pleroma.Web.Federator, []),
79 worker(Pleroma.Stats, []),
80 worker(Pleroma.Web.Push, [])
81 ] ++
82 streamer_child() ++
83 chat_child() ++
84 [
85 # Start the endpoint when the application starts
86 supervisor(Pleroma.Web.Endpoint, []),
87 worker(Pleroma.Gopher.Server, [])
88 ]
89
90 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
91 # for other strategies and supported options
92 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
93 Supervisor.start_link(children, opts)
94 end
95
96 if Mix.env() == :test do
97 defp streamer_child(), do: []
98 defp chat_child(), do: []
99 else
100 defp streamer_child() do
101 [worker(Pleroma.Web.Streamer, [])]
102 end
103
104 defp chat_child() do
105 if Pleroma.Config.get([:chat, :enabled]) do
106 [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
107 else
108 []
109 end
110 end
111 end
112 end