-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathapplication.ex
More file actions
48 lines (41 loc) · 1.56 KB
/
application.ex
File metadata and controls
48 lines (41 loc) · 1.56 KB
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
import Supervisor.Spec
# Define workers and child supervisors to be supervised
children = [
# Start the Ecto repository
supervisor(Cadet.Repo, []),
# Start the endpoint when the application starts
supervisor(CadetWeb.Endpoint, []),
{Phoenix.PubSub, [name: Cadet.PubSub, adapter: Phoenix.PubSub.PG2]},
# Start your own worker by calling: Cadet.Worker.start_link(arg1, arg2, arg3)
# worker(Cadet.Worker, [arg1, arg2, arg3]),
# Start the GuardianDB sweeper
worker(Guardian.DB.Token.Sweeper, []),
# Start the Quantum scheduler
worker(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 ++ [worker(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