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