Improved version string
[akkoma] / lib / pleroma / application.ex
1 defmodule Pleroma.Application do
2 use Application
3
4 @name "Pleroma"
5 @version Mix.Project.config()[:version]
6 def name, do: @name
7 def version, do: @version
8 def named_version(), do: @name <> " " <> @version
9
10 # See http://elixir-lang.org/docs/stable/elixir/Application.html
11 # for more information on OTP Applications
12 def start(_type, _args) do
13 import Supervisor.Spec
14 import Cachex.Spec
15
16 # Define workers and child supervisors to be supervised
17 children =
18 [
19 # Start the Ecto repository
20 supervisor(Pleroma.Repo, []),
21 worker(Pleroma.Emoji, []),
22 # Start the endpoint when the application starts
23 supervisor(Pleroma.Web.Endpoint, []),
24 # Start your own worker by calling: Pleroma.Worker.start_link(arg1, arg2, arg3)
25 # worker(Pleroma.Worker, [arg1, arg2, arg3]),
26 worker(
27 Cachex,
28 [
29 :user_cache,
30 [
31 default_ttl: 25000,
32 ttl_interval: 1000,
33 limit: 2500
34 ]
35 ],
36 id: :cachex_user
37 ),
38 worker(
39 Cachex,
40 [
41 :object_cache,
42 [
43 default_ttl: 25000,
44 ttl_interval: 1000,
45 limit: 2500
46 ]
47 ],
48 id: :cachex_object
49 ),
50 worker(
51 Cachex,
52 [
53 :idempotency_cache,
54 [
55 expiration:
56 expiration(
57 default: :timer.seconds(6 * 60 * 60),
58 interval: :timer.seconds(60)
59 ),
60 limit: 2500
61 ]
62 ],
63 id: :cachex_idem
64 ),
65 worker(Pleroma.Web.Federator, []),
66 worker(Pleroma.Stats, []),
67 worker(Pleroma.Gopher.Server, [])
68 ] ++
69 if Mix.env() == :test,
70 do: [],
71 else:
72 [worker(Pleroma.Web.Streamer, [])] ++
73 if(
74 !chat_enabled(),
75 do: [],
76 else: [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
77 )
78
79 # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
80 # for other strategies and supported options
81 opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
82 Supervisor.start_link(children, opts)
83 end
84
85 defp chat_enabled do
86 Application.get_env(:pleroma, :chat, []) |> Keyword.get(:enabled)
87 end
88 end