1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-11-18 10:59:17 +00:00
akkoma/lib/pleroma/application.ex

91 lines
2.4 KiB
Elixir
Raw Normal View History

2017-03-17 16:09:58 +00:00
defmodule Pleroma.Application do
use Application
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
2017-03-17 16:09:58 +00:00
# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
2018-11-16 20:35:08 +00:00
@env Mix.env()
2017-03-17 16:09:58 +00:00
def start(_type, _args) do
import Supervisor.Spec
import Cachex.Spec
2017-03-17 16:09:58 +00:00
# Define workers and child supervisors to be supervised
2018-03-30 14:01:53 +01:00
children =
[
# Start the Ecto repository
supervisor(Pleroma.Repo, []),
worker(Pleroma.Emoji, []),
# Start the endpoint when the application starts
supervisor(Pleroma.Web.Endpoint, []),
2018-03-30 14:01:53 +01:00
# Start your own worker by calling: Pleroma.Worker.start_link(arg1, arg2, arg3)
# worker(Pleroma.Worker, [arg1, arg2, arg3]),
worker(
Cachex,
2018-03-30 14:01:53 +01:00
[
:user_cache,
[
default_ttl: 25000,
ttl_interval: 1000,
limit: 2500
]
],
id: :cachex_user
),
worker(
Cachex,
[
:object_cache,
[
default_ttl: 25000,
ttl_interval: 1000,
limit: 2500
]
],
id: :cachex_object
),
worker(
Cachex,
[
:idempotency_cache,
[
expiration:
expiration(
default: :timer.seconds(6 * 60 * 60),
interval: :timer.seconds(60)
),
limit: 2500
]
],
id: :cachex_idem
),
2018-03-30 14:01:53 +01:00
worker(Pleroma.Web.Federator, []),
2018-08-26 19:17:13 +01:00
worker(Pleroma.Web.Federator.RetryQueue, []),
worker(Pleroma.Gopher.Server, []),
worker(Pleroma.Stats, [])
2018-03-30 14:01:53 +01:00
] ++
2018-11-16 20:35:08 +00:00
if @env == :test,
2018-03-30 14:01:53 +01:00
do: [],
else:
[worker(Pleroma.Web.Streamer, [])] ++
if(
!chat_enabled(),
do: [],
else: [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
)
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
defp chat_enabled do
Application.get_env(:pleroma, :chat, []) |> Keyword.get(:enabled)
end
2017-03-17 16:09:58 +00:00
end