show warning if VAPID is not set
[akkoma] / lib / pleroma / application.ex
1 defmodule Pleroma.Application do
2 use Application
3
4 @name "Pleroma"
5 @version Mix.Project.config()[:version]
6 def name, do: @name
7 def version, do: @version
8 def named_version(), do: @name <> " " <> @version
9
10 # See http://elixir-lang.org/docs/stable/elixir/Application.html
11 # for more information on OTP Applications
12 @env Mix.env()
13 def start(_type, _args) do
14 import Supervisor.Spec
15 import Cachex.Spec
16
17 # Define workers and child supervisors to be supervised
18 children =
19 [
20 # Start the Ecto repository
21 supervisor(Pleroma.Repo, []),
22 worker(Pleroma.Emoji, []),
23 # Start the endpoint when the application starts
24 supervisor(Pleroma.Web.Endpoint, []),
25 # Start your own worker by calling: Pleroma.Worker.start_link(arg1, arg2, arg3)
26 # worker(Pleroma.Worker, [arg1, arg2, arg3]),
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, []),
67 worker(Pleroma.Web.Federator.RetryQueue, []),
68 worker(Pleroma.Gopher.Server, []),
69 worker(Pleroma.Stats, []),
70 worker(Pleroma.Web.Push, [])
71 ] ++
72 if @env == :test,
73 do: [],
74 else:
75 [worker(Pleroma.Web.Streamer, [])] ++
76 if(
77 !chat_enabled(),
78 do: [],
79 else: [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
80 )
81
82 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
83 # for other strategies and supported options
84 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
85 Supervisor.start_link(children, opts)
86 end
87
88 defp chat_enabled do
89 Application.get_env(:pleroma, :chat, []) |> Keyword.get(:enabled)
90 end
91 end