-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathapplication.ex
48 lines (42 loc) · 1.62 KB
/
application.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
defmodule Cadet.Application do
@moduledoc false
use Application
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
def start(_type, _args) do
# Define workers and child supervisors to be supervised
# No need to distinguish between workers and supervisors anymore
# https://kobrakai.de/kolumne/child-specs-in-elixir/
children = [
# Start the Ecto repository
{Cadet.Repo, []},
# Start the endpoint when the application starts
{CadetWeb.Endpoint, []},
{Phoenix.PubSub, [name: Cadet.PubSub, adapter: Phoenix.PubSub.PG2]},
# Start your own worker by calling: Cadet.Worker.start_link(arg1, arg2, arg3)
# {Cadet.Worker, [arg1, arg2, arg3]},
# Start the GuardianDB sweeper
{Guardian.DB.Token.SweeperServer, []},
# Start the Quantum scheduler
{Cadet.Jobs.Scheduler, []},
# Start the Oban instance
{Oban, Application.fetch_env!(:cadet, Oban)}
]
children =
case Application.get_env(:cadet, :openid_connect_providers) do
nil -> children
providers -> children ++ [{OpenIDConnect.Worker, [providers]}]
end
{:ok, _} = Logger.add_backend(Sentry.LoggerBackend)
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Cadet.Supervisor]
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
CadetWeb.Endpoint.config_change(changed, removed)
:ok
end
end