From 1e4de6e41e2936dd4629f70e72f5dde95972698c Mon Sep 17 00:00:00 2001 From: saneery Date: Tue, 23 Jul 2019 12:07:09 +0300 Subject: [PATCH] Add env to disable indexer supervisor --- apps/indexer/config/config.exs | 2 ++ apps/indexer/lib/indexer/application.ex | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/indexer/config/config.exs b/apps/indexer/config/config.exs index 4e84e9bcfe..b01a09c450 100644 --- a/apps/indexer/config/config.exs +++ b/apps/indexer/config/config.exs @@ -41,6 +41,8 @@ config :indexer, # config :indexer, Indexer.Fetcher.BlockReward.Supervisor, disabled?: true config :indexer, Indexer.Fetcher.StakingPools.Supervisor, disabled?: true +config :indexer, Indexer.Supervisor, enabled: System.get_env("DISABLE_INDEXER") != "true" + config :indexer, Indexer.Tracer, service: :indexer, adapter: SpandexDatadog.Adapter, diff --git a/apps/indexer/lib/indexer/application.ex b/apps/indexer/lib/indexer/application.ex index cb696567b7..f261ba8057 100644 --- a/apps/indexer/lib/indexer/application.ex +++ b/apps/indexer/lib/indexer/application.ex @@ -17,11 +17,17 @@ defmodule Indexer.Application do memory_monitor_name = Memory.Monitor - children = [ - {Memory.Monitor, [memory_monitor_options, [name: memory_monitor_name]]}, - {Indexer.Supervisor, [%{memory_monitor: memory_monitor_name}]} + base_children = [ + {Memory.Monitor, [memory_monitor_options, [name: memory_monitor_name]]} ] + children = + if Application.get_env(:indexer, Indexer.Supervisor)[:enabled] do + Enum.reverse([{Indexer.Supervisor, [%{memory_monitor: memory_monitor_name}]} | base_children]) + else + base_children + end + opts = [ # If the `Memory.Monitor` dies, it needs all the `Shrinkable`s to re-register, so restart them. strategy: :rest_for_one,