Add web push support
[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 # Start the Ecto repository
14 supervisor(Pleroma.Repo, []),
15 # Start the endpoint when the application starts
16 supervisor(Pleroma.Web.Endpoint, []),
17 # Start your own worker by calling: Pleroma.Worker.start_link(arg1, arg2, arg3)
18 # worker(Pleroma.Worker, [arg1, arg2, arg3]),
19 worker(Cachex, [
20 :user_cache,
21 [
22 default_ttl: 25000,
23 ttl_interval: 1000,
24 limit: 2500
25 ]
26 ]),
27 worker(
28 Cachex,
29 [
30 :idempotency_cache,
31 [
32 expiration:
33 expiration(
34 default: :timer.seconds(6 * 60 * 60),
35 interval: :timer.seconds(60)
36 ),
37 limit: 2500
38 ]
39 ],
40 id: :cachex_idem
41 ),
42 worker(Pleroma.Web.Federator, []),
43 worker(Pleroma.Gopher.Server, []),
44 worker(Pleroma.Stats, []),
45 worker(Pleroma.Web.Push, [])
46 ] ++
47 if Mix.env() == :test,
48 do: [],
49 else:
50 [worker(Pleroma.Web.Streamer, [])] ++
51 if(
52 !chat_enabled(),
53 do: [],
54 else: [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
55 )
56
57 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
58 # for other strategies and supported options
59 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
60 Supervisor.start_link(children, opts)
61 end
62
63 defp chat_enabled do
64 Application.get_env(:pleroma, :chat, []) |> Keyword.get(:enabled)
65 end
66 end