-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathapplication.ex
More file actions
68 lines (54 loc) · 2.1 KB
/
Copy pathapplication.ex
File metadata and controls
68 lines (54 loc) · 2.1 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
57
58
59
60
61
62
63
64
65
66
67
68
defmodule GithubNotifier.Application do
require Logger
use Application
def start(_type, _args) do
alias GithubNotifier.Services
env = Application.get_env(:github_notifier, :environment)
Logger.info("Running application in #{env} environment")
# Disables too verbose logging from amqp supervisors
:logger.add_primary_filter(
:ignore_rabbitmq_progress_reports,
{&:logger_filters.domain/2, {:stop, :equal, [:progress]}}
)
children =
filter_enabled([
{{GRPC.Server.Supervisor, {grpc_services(), 50_051}}, enabled?("START_API")},
{{Services.BlockFinishedNotifier, []}, enabled?("START_CONSUMERS")},
{{Services.PipelineStartedNotifier, []}, enabled?("START_CONSUMERS")},
{{Services.PipelineFinishedNotifier, []}, enabled?("START_CONSUMERS")},
{{Services.PipelineSummaryAvailableNotifier, []}, enabled?("START_CONSUMERS")},
{{GithubNotifier.FeatureProviderInvalidatorWorker, []}, true},
feature_provider()
])
children =
children ++
[
{Task.Supervisor, name: GithubNotifier.TaskSupervisor},
%{id: Cachex, start: {Cachex, :start_link, [:store, []]}},
%{
id: FeatureProvider.Cachex,
start: {Cachex, :start_link, [:feature_provider_cache, []]}
}
]
Enum.each(children, fn c ->
Logger.info("Starting: #{inspect(c)}")
end)
{:ok, _} = Logger.add_backend(Sentry.LoggerBackend)
Logger.configure_backend(Sentry.LoggerBackend, include_logger_metadata: true)
opts = [strategy: :one_for_one, name: GithubNotifier.Supervisor, max_restarts: 1000]
Supervisor.start_link(children, opts)
end
defp enabled?(env_var) do
System.get_env(env_var) == "true" && !IEx.started?()
end
defp filter_enabled(list) do
list
|> Enum.filter(fn e -> elem(e, 1) end)
|> Enum.map(fn e -> elem(e, 0) end)
end
defp grpc_services, do: [GithubNotifier.Services.Api]
defp feature_provider do
provider = Application.get_env(FeatureProvider, :provider)
{provider, System.get_env("FEATURE_YAML_PATH") != nil}
end
end