2017-03-17 17:09:58 +01:00
|
|
|
defmodule Pleroma.Application do
|
|
|
|
use Application
|
|
|
|
|
|
|
|
# See http://elixir-lang.org/docs/stable/elixir/Application.html
|
|
|
|
# for more information on OTP Applications
|
|
|
|
def start(_type, _args) do
|
|
|
|
import Supervisor.Spec
|
|
|
|
|
|
|
|
# Define workers and child supervisors to be supervised
|
2018-03-30 15:01:53 +02:00
|
|
|
children =
|
|
|
|
[
|
|
|
|
# Start the Ecto repository
|
|
|
|
supervisor(Pleroma.Repo, []),
|
|
|
|
# Start the endpoint when the application starts
|
|
|
|
supervisor(Pleroma.Web.Endpoint, []),
|
|
|
|
# Start your own worker by calling: Pleroma.Worker.start_link(arg1, arg2, arg3)
|
|
|
|
# worker(Pleroma.Worker, [arg1, arg2, arg3]),
|
|
|
|
worker(Cachex, [
|
|
|
|
:user_cache,
|
|
|
|
[
|
|
|
|
default_ttl: 25000,
|
|
|
|
ttl_interval: 1000,
|
|
|
|
limit: 2500
|
|
|
|
]
|
|
|
|
]),
|
2018-05-05 11:15:57 +02:00
|
|
|
worker(
|
|
|
|
Cachex,
|
|
|
|
[
|
|
|
|
:idempotency_cache,
|
|
|
|
[
|
|
|
|
default_ttl: :timer.seconds(6 * 60 * 60),
|
|
|
|
ttl_interval: :timer.seconds(60),
|
|
|
|
limit: 2500
|
|
|
|
]
|
|
|
|
],
|
|
|
|
id: :cachex_idem
|
|
|
|
),
|
2018-03-30 15:01:53 +02:00
|
|
|
worker(Pleroma.Web.Federator, []),
|
2018-03-31 17:51:33 +02:00
|
|
|
worker(Pleroma.Gopher.Server, []),
|
2018-03-30 15:01:53 +02:00
|
|
|
worker(Pleroma.Stats, [])
|
|
|
|
] ++
|
|
|
|
if Mix.env() == :test,
|
|
|
|
do: [],
|
|
|
|
else:
|
|
|
|
[worker(Pleroma.Web.Streamer, [])] ++
|
|
|
|
if(
|
|
|
|
!chat_enabled(),
|
|
|
|
do: [],
|
|
|
|
else: [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
|
|
|
|
)
|
2017-03-17 17:09:58 +01:00
|
|
|
|
|
|
|
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
|
|
|
|
# for other strategies and supported options
|
|
|
|
opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
|
|
|
|
Supervisor.start_link(children, opts)
|
|
|
|
end
|
2018-02-01 18:23:26 +01:00
|
|
|
|
|
|
|
defp chat_enabled do
|
|
|
|
Application.get_env(:pleroma, :chat, []) |> Keyword.get(:enabled)
|
|
|
|
end
|
2017-03-17 17:09:58 +01:00
|
|
|
end
|