From dd191cbe081caeb875c0a0d288680ecaa81291b6 Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop Date: Tue, 12 Jul 2022 23:09:20 +0400 Subject: [PATCH] Disable realtime fetcher by env --- apps/indexer/config/config.exs | 2 ++ apps/indexer/lib/indexer/supervisor.ex | 28 +++++++++++++++++------ docker-compose/envs/common-blockscout.env | 1 + docker/Makefile | 3 +++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/apps/indexer/config/config.exs b/apps/indexer/config/config.exs index 7f6b6f9b7a..0402ffc5a9 100644 --- a/apps/indexer/config/config.exs +++ b/apps/indexer/config/config.exs @@ -82,6 +82,8 @@ config :indexer, Indexer.Fetcher.EmptyBlocksSanitizer.Supervisor, config :indexer, Indexer.Supervisor, enabled: System.get_env("DISABLE_INDEXER") != "true" +config :indexer, Indexer.Block.Realtime.Supervisor, enabled: System.get_env("DISABLE_REALTIME_INDEXER") != "true" + config :indexer, Indexer.Tracer, service: :indexer, adapter: SpandexDatadog.Adapter, diff --git a/apps/indexer/lib/indexer/supervisor.ex b/apps/indexer/lib/indexer/supervisor.ex index 1636bedcda..50770c23d1 100644 --- a/apps/indexer/lib/indexer/supervisor.ex +++ b/apps/indexer/lib/indexer/supervisor.ex @@ -92,14 +92,21 @@ defmodule Indexer.Supervisor do realtime_subscribe_named_arguments = realtime_overrides[:subscribe_named_arguments] || subscribe_named_arguments + realtime_fetcher = + if Application.get_env(:indexer, Realtime.Supervisor)[:enabled] do + [ + {Realtime.Supervisor, + [ + %{block_fetcher: realtime_block_fetcher, subscribe_named_arguments: realtime_subscribe_named_arguments}, + [name: Realtime.Supervisor] + ]} + ] + else + [] + end + basic_fetchers = [ # Root fetchers - {PendingTransaction.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments]]}, - {Realtime.Supervisor, - [ - %{block_fetcher: realtime_block_fetcher, subscribe_named_arguments: realtime_subscribe_named_arguments}, - [name: Realtime.Supervisor] - ]}, {Catchup.Supervisor, [ %{block_fetcher: block_fetcher, block_interval: block_interval, memory_monitor: memory_monitor}, @@ -135,8 +142,15 @@ defmodule Indexer.Supervisor do {PendingOpsCleaner, [[], []]} ] + all_fetchers = + [ + {PendingTransaction.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments]]} + ] ++ + realtime_fetcher ++ + basic_fetchers + Supervisor.init( - basic_fetchers, + all_fetchers, strategy: :one_for_one ) end diff --git a/docker-compose/envs/common-blockscout.env b/docker-compose/envs/common-blockscout.env index 03036522fc..212a744554 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -75,6 +75,7 @@ DISABLE_WEBAPP=false DISABLE_READ_API=false DISABLE_WRITE_API=false DISABLE_INDEXER=false +DISABLE_REALTIME_INDEXER=false INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER=false INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false # WEBAPP_URL= diff --git a/docker/Makefile b/docker/Makefile index f2e0d9a3bb..dc9434895a 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -172,6 +172,9 @@ endif ifdef DISABLE_INDEXER BLOCKSCOUT_CONTAINER_PARAMS += -e 'DISABLE_INDEXER=$(DISABLE_INDEXER)' endif +ifdef DISABLE_REALTIME_INDEXER + BLOCKSCOUT_CONTAINER_PARAMS += -e 'DISABLE_REALTIME_INDEXER=$(DISABLE_REALTIME_INDEXER)' +endif ifdef WEBAPP_URL BLOCKSCOUT_CONTAINER_PARAMS += -e 'WEBAPP_URL=$(WEBAPP_URL)' endif