d4bc8f63de26d59813b506e2ae10b45a9292f795
[akkoma] / lib / pleroma / application.ex
1 defmodule Pleroma.Application do
2 use Application
3
4 # See http://elixir-lang.org/docs/stable/elixir/Application.html
5 # for more information on OTP Applications
6 def start(_type, _args) do
7 import Supervisor.Spec
8 import Cachex.Spec
9
10 # Define workers and child supervisors to be supervised
11 children =
12 [
13 worker(Pleroma.Config, [Application.get_all_env(:pleroma)]),
14 # Start the Ecto repository
15 supervisor(Pleroma.Repo, []),
16 worker(Pleroma.Emoji, []),
17 # Start the endpoint when the application starts
18 supervisor(Pleroma.Web.Endpoint, []),
19 # Start your own worker by calling: Pleroma.Worker.start_link(arg1, arg2, arg3)
20 # worker(Pleroma.Worker, [arg1, arg2, arg3]),
21 worker(
22 Cachex,
23 [
24 :user_cache,
25 [
26 default_ttl: 25000,
27 ttl_interval: 1000,
28 limit: 2500
29 ]
30 ],
31 id: :cachex_user
32 ),
33 worker(
34 Cachex,
35 [
36 :object_cache,
37 [
38 default_ttl: 25000,
39 ttl_interval: 1000,
40 limit: 2500
41 ]
42 ],
43 id: :cachex_object
44 ),
45 worker(
46 Cachex,
47 [
48 :idempotency_cache,
49 [
50 expiration:
51 expiration(
52 default: :timer.seconds(6 * 60 * 60),
53 interval: :timer.seconds(60)
54 ),
55 limit: 2500
56 ]
57 ],
58 id: :cachex_idem
59 ),
60 worker(Pleroma.Web.Federator, []),
61 worker(Pleroma.Stats, []),
62 worker(Pleroma.Gopher.Server, [])
63 ] ++
64 if Mix.env() == :test,
65 do: [],
66 else:
67 [worker(Pleroma.Web.Streamer, [])] ++
68 if(
69 !chat_enabled(),
70 do: [],
71 else: [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
72 )
73
74 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
75 # for other strategies and supported options
76 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
77 Supervisor.start_link(children, opts)
78 end
79
80 defp chat_enabled do
81 Application.get_env(:pleroma, :chat, []) |> Keyword.get(:enabled)
82 end
83 end