2018-12-23 20:04:54 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2017-03-17 16:09:58 +00:00
|
|
|
defmodule Pleroma.Application do
|
|
|
|
use Application
|
2018-11-19 19:58:12 +00:00
|
|
|
import Supervisor.Spec
|
2017-03-17 16:09:58 +00:00
|
|
|
|
2018-11-20 16:55:03 +00:00
|
|
|
@name "Pleroma"
|
|
|
|
@version Mix.Project.config()[:version]
|
|
|
|
def name, do: @name
|
|
|
|
def version, do: @version
|
|
|
|
def named_version(), do: @name <> " " <> @version
|
|
|
|
|
2018-11-23 16:40:45 +00:00
|
|
|
def user_agent() do
|
|
|
|
info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
|
|
|
|
named_version() <> "; " <> info
|
|
|
|
end
|
|
|
|
|
2017-03-17 16:09:58 +00:00
|
|
|
# See http://elixir-lang.org/docs/stable/elixir/Application.html
|
|
|
|
# for more information on OTP Applications
|
|
|
|
def start(_type, _args) do
|
2018-05-20 16:05:34 +00:00
|
|
|
import Cachex.Spec
|
2017-03-17 16:09:58 +00:00
|
|
|
|
|
|
|
# Define workers and child supervisors to be supervised
|
2018-03-30 13:01:53 +00:00
|
|
|
children =
|
|
|
|
[
|
|
|
|
# Start the Ecto repository
|
|
|
|
supervisor(Pleroma.Repo, []),
|
2018-11-05 12:24:00 +00:00
|
|
|
worker(Pleroma.Emoji, []),
|
2018-12-14 22:31:19 +00:00
|
|
|
worker(Pleroma.Captcha, []),
|
2018-11-01 08:30:10 +00:00
|
|
|
worker(
|
|
|
|
Cachex,
|
2018-03-30 13:01:53 +00:00
|
|
|
[
|
2018-11-01 08:30:10 +00:00
|
|
|
:user_cache,
|
|
|
|
[
|
|
|
|
default_ttl: 25000,
|
|
|
|
ttl_interval: 1000,
|
|
|
|
limit: 2500
|
|
|
|
]
|
|
|
|
],
|
|
|
|
id: :cachex_user
|
|
|
|
),
|
|
|
|
worker(
|
|
|
|
Cachex,
|
2018-03-30 13:01:53 +00:00
|
|
|
[
|
2018-11-01 08:30:10 +00:00
|
|
|
:object_cache,
|
|
|
|
[
|
|
|
|
default_ttl: 25000,
|
|
|
|
ttl_interval: 1000,
|
|
|
|
limit: 2500
|
|
|
|
]
|
|
|
|
],
|
|
|
|
id: :cachex_object
|
|
|
|
),
|
2018-05-05 09:15:57 +00:00
|
|
|
worker(
|
|
|
|
Cachex,
|
|
|
|
[
|
|
|
|
:idempotency_cache,
|
|
|
|
[
|
2018-05-20 16:05:34 +00:00
|
|
|
expiration:
|
|
|
|
expiration(
|
|
|
|
default: :timer.seconds(6 * 60 * 60),
|
|
|
|
interval: :timer.seconds(60)
|
|
|
|
),
|
2018-05-05 09:15:57 +00:00
|
|
|
limit: 2500
|
|
|
|
]
|
|
|
|
],
|
|
|
|
id: :cachex_idem
|
|
|
|
),
|
2018-08-26 18:17:13 +00:00
|
|
|
worker(Pleroma.Web.Federator.RetryQueue, []),
|
2018-11-19 19:58:12 +00:00
|
|
|
worker(Pleroma.Web.Federator, []),
|
2018-12-06 12:29:04 +00:00
|
|
|
worker(Pleroma.Stats, []),
|
|
|
|
worker(Pleroma.Web.Push, [])
|
2018-03-30 13:01:53 +00:00
|
|
|
] ++
|
2018-11-19 19:58:12 +00:00
|
|
|
streamer_child() ++
|
|
|
|
chat_child() ++
|
|
|
|
[
|
|
|
|
# Start the endpoint when the application starts
|
|
|
|
supervisor(Pleroma.Web.Endpoint, []),
|
|
|
|
worker(Pleroma.Gopher.Server, [])
|
|
|
|
]
|
2017-03-17 16:09:58 +00: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 17:23:26 +00:00
|
|
|
|
2018-11-19 19:58:12 +00:00
|
|
|
if Mix.env() == :test do
|
|
|
|
defp streamer_child(), do: []
|
|
|
|
defp chat_child(), do: []
|
|
|
|
else
|
|
|
|
defp streamer_child() do
|
|
|
|
[worker(Pleroma.Web.Streamer, [])]
|
|
|
|
end
|
|
|
|
|
|
|
|
defp chat_child() do
|
|
|
|
if Pleroma.Config.get([:chat, :enabled]) do
|
|
|
|
[worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
|
|
|
|
else
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
end
|
2018-02-01 17:23:26 +00:00
|
|
|
end
|
2017-03-17 16:09:58 +00:00
|
|
|
end
|