-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathapplication.ex
More file actions
56 lines (48 loc) · 1.55 KB
/
application.ex
File metadata and controls
56 lines (48 loc) · 1.55 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
49
50
51
52
53
54
55
56
defmodule Diff.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
def start(_type, _args) do
:logger.add_handler(:sentry_handler, Sentry.LoggerHandler, %{})
# List all child processes to be supervised
children = [
goth_spec(),
{Task.Supervisor, name: Diff.Tasks},
{Phoenix.PubSub, name: Diff.PubSub},
Diff.Package.Supervisor,
DiffWeb.Endpoint
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Diff.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
DiffWeb.Endpoint.config_change(changed, removed)
:ok
end
def sentry_before_send(%Sentry.Event{original_exception: exception} = event) do
cond do
Plug.Exception.status(exception) < 500 -> nil
Sentry.DefaultEventFilter.exclude_exception?(exception, event.source) -> nil
true -> event
end
end
if Mix.env() == :prod do
defp goth_spec() do
credentials =
"DIFF_GCP_CREDENTIALS"
|> System.fetch_env!()
|> Jason.decode!()
options = [scope: "https://www.googleapis.com/auth/devstorage.read_write"]
{Goth, name: Diff.Goth, source: {:service_account, credentials, options}}
end
else
defp goth_spec() do
{Task, fn -> :ok end}
end
end
end