2018-10-11 17:37:39 +02:00
|
|
|
defmodule Mobilizon.Application do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
2018-10-11 17:37:39 +02:00
|
|
|
The Mobilizon application
|
2018-01-14 17:56:50 +01:00
|
|
|
"""
|
2017-12-08 09:58:14 +01:00
|
|
|
use Application
|
2019-03-01 12:57:22 +01:00
|
|
|
import Cachex.Spec
|
2017-12-08 09:58:14 +01:00
|
|
|
|
|
|
|
# See https://hexdocs.pm/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
|
|
|
|
children = [
|
|
|
|
# Start the Ecto repository
|
2018-10-11 17:37:39 +02:00
|
|
|
supervisor(Mobilizon.Repo, []),
|
2017-12-08 09:58:14 +01:00
|
|
|
# Start the endpoint when the application starts
|
2018-10-11 17:37:39 +02:00
|
|
|
supervisor(MobilizonWeb.Endpoint, []),
|
|
|
|
# Start your own worker by calling: Mobilizon.Worker.start_link(arg1, arg2, arg3)
|
|
|
|
# worker(Mobilizon.Worker, [arg1, arg2, arg3]),
|
2019-03-01 12:57:22 +01:00
|
|
|
worker(
|
|
|
|
Cachex,
|
|
|
|
[
|
|
|
|
:feed,
|
|
|
|
[
|
|
|
|
limit: 2500,
|
|
|
|
expiration:
|
|
|
|
expiration(
|
|
|
|
default: :timer.minutes(60),
|
|
|
|
interval: :timer.seconds(60)
|
|
|
|
),
|
|
|
|
fallback: fallback(default: &Mobilizon.Service.Feed.create_cache/1)
|
|
|
|
]
|
|
|
|
],
|
|
|
|
id: :cache_feed
|
|
|
|
),
|
|
|
|
worker(
|
|
|
|
Cachex,
|
|
|
|
[
|
2019-03-01 18:30:46 +01:00
|
|
|
:activity_pub,
|
2019-03-01 12:57:22 +01:00
|
|
|
[
|
2019-03-01 18:30:46 +01:00
|
|
|
limit: 2500,
|
|
|
|
expiration:
|
|
|
|
expiration(
|
|
|
|
default: :timer.minutes(3),
|
|
|
|
interval: :timer.seconds(15)
|
|
|
|
)
|
2019-03-01 12:57:22 +01:00
|
|
|
]
|
|
|
|
],
|
2019-03-01 18:30:46 +01:00
|
|
|
id: :cache_activity_pub
|
2019-03-01 12:57:22 +01:00
|
|
|
),
|
2018-05-17 11:32:23 +02:00
|
|
|
worker(Guardian.DB.Token.SweeperServer, []),
|
2018-10-11 17:37:39 +02:00
|
|
|
worker(Mobilizon.Service.Federator, [])
|
2017-12-08 09:58:14 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
# See https://hexdocs.pm/elixir/Supervisor.html
|
|
|
|
# for other strategies and supported options
|
2018-10-11 17:37:39 +02:00
|
|
|
opts = [strategy: :one_for_one, name: Mobilizon.Supervisor]
|
2017-12-08 09:58:14 +01:00
|
|
|
Supervisor.start_link(children, opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Tell Phoenix to update the endpoint configuration
|
|
|
|
# whenever the application is updated.
|
|
|
|
def config_change(changed, _new, removed) do
|
2018-10-11 17:37:39 +02:00
|
|
|
MobilizonWeb.Endpoint.config_change(changed, removed)
|
2017-12-08 09:58:14 +01:00
|
|
|
:ok
|
|
|
|
end
|
|
|
|
end
|