Format the code.
[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
9 # Define workers and child supervisors to be supervised
10 children =
11 [
12 # Start the Ecto repository
13 supervisor(Pleroma.Repo, []),
14 # Start the endpoint when the application starts
15 supervisor(Pleroma.Web.Endpoint, []),
16 # Start your own worker by calling: Pleroma.Worker.start_link(arg1, arg2, arg3)
17 # worker(Pleroma.Worker, [arg1, arg2, arg3]),
18 worker(Cachex, [
19 :user_cache,
20 [
21 default_ttl: 25000,
22 ttl_interval: 1000,
23 limit: 2500
24 ]
25 ]),
26 worker(Pleroma.Web.Federator, []),
27 worker(Pleroma.Stats, [])
28 ] ++
29 if Mix.env() == :test,
30 do: [],
31 else:
32 [worker(Pleroma.Web.Streamer, [])] ++
33 if(
34 !chat_enabled(),
35 do: [],
36 else: [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
37 )
38
39 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
40 # for other strategies and supported options
41 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
42 Supervisor.start_link(children, opts)
43 end
44
45 defp chat_enabled do
46 Application.get_env(:pleroma, :chat, []) |> Keyword.get(:enabled)
47 end
48 end