Various Docker setup fixes

pull/5196/head
Viktor Baranov 3 years ago
parent 14da1e8f1c
commit 6fa2c0b740
  1. 1
      CHANGELOG.md
  2. 14
      apps/explorer/config/dev.exs
  3. 14
      apps/explorer/config/prod.exs
  4. 3
      apps/indexer/config/config.exs
  5. 48
      apps/indexer/lib/indexer/block/catchup/bound_interval_supervisor.ex
  6. 37
      docker/Makefile

@ -5,6 +5,7 @@
- [#4690](https://github.com/blockscout/blockscout/pull/4690) - Improve pagination: introduce pagination with random access to pages; Integrate it to the Transactions List page
### Fixes
- [#5196](https://github.com/blockscout/blockscout/pull/5196) - Various Docker setup fixes
- [#5192](https://github.com/blockscout/blockscout/pull/5192) - Fix DATABASE_URL config parser
- [#5191](https://github.com/blockscout/blockscout/pull/5191) - Add empty view for new addresses
- [#5184](https://github.com/blockscout/blockscout/pull/5184) - eth_call method: remove from param from the request, if it is null

@ -8,23 +8,33 @@ database_api_url =
do: System.get_env("DATABASE_READ_ONLY_API_URL"),
else: System.get_env("DATABASE_URL")
pool_size =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE_API", "40")),
else: String.to_integer(System.get_env("POOL_SIZE_API", "50"))
# Configure your database
config :explorer, Explorer.Repo,
database: database,
hostname: hostname,
url: System.get_env("DATABASE_URL"),
pool_size: String.to_integer(System.get_env("POOL_SIZE", "50")),
pool_size: pool_size,
timeout: :timer.seconds(80)
database_api = if System.get_env("DATABASE_READ_ONLY_API_URL"), do: nil, else: database
hostname_api = if System.get_env("DATABASE_READ_ONLY_API_URL"), do: nil, else: hostname
pool_size_api =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE_API", "50")),
else: String.to_integer(System.get_env("POOL_SIZE_API", "10"))
# Configure API database
config :explorer, Explorer.Repo.Replica1,
database: database_api,
hostname: hostname_api,
url: database_api_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE_API", "50")),
pool_size: pool_size_api,
timeout: :timer.seconds(80)
config :explorer, Explorer.Tracer, env: "dev", disabled?: true

@ -1,9 +1,14 @@
use Mix.Config
pool_size =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE_API", "50")),
else: String.to_integer(System.get_env("POOL_SIZE_API", "40"))
# Configures the database
config :explorer, Explorer.Repo,
url: System.get_env("DATABASE_URL"),
pool_size: String.to_integer(System.get_env("POOL_SIZE", "50")),
pool_size: pool_size,
ssl: String.equivalent?(System.get_env("ECTO_USE_SSL") || "true", "true"),
prepare: :unnamed,
timeout: :timer.seconds(60)
@ -13,10 +18,15 @@ database_api_url =
do: System.get_env("DATABASE_READ_ONLY_API_URL"),
else: System.get_env("DATABASE_URL")
pool_size_api =
if System.get_env("DATABASE_READ_ONLY_API_URL"),
do: String.to_integer(System.get_env("POOL_SIZE_API", "50")),
else: String.to_integer(System.get_env("POOL_SIZE_API", "10"))
# Configures API the database
config :explorer, Explorer.Repo.Replica1,
url: database_api_url,
pool_size: String.to_integer(System.get_env("POOL_SIZE_API", "50")),
pool_size: pool_size_api,
ssl: String.equivalent?(System.get_env("ECTO_USE_SSL") || "true", "true"),
prepare: :unnamed,
timeout: :timer.seconds(60)

@ -64,7 +64,8 @@ else
config :indexer, Indexer.Fetcher.BlockReward.Supervisor, disabled?: false
end
config :indexer, Indexer.Fetcher.InternalTransaction.Supervisor, disabled?: false
config :indexer, Indexer.Fetcher.InternalTransaction.Supervisor,
disabled?: System.get_env("INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER", "false") == "true"
config :indexer, Indexer.Supervisor, enabled: System.get_env("DISABLE_INDEXER") != "true"

@ -275,6 +275,54 @@ defmodule Indexer.Block.Catchup.BoundIntervalSupervisor do
{:noreply, %__MODULE__{state | task: nil}}
end
def handle_info(
{ref, {:error, :econnrefused}},
%__MODULE__{
fetcher: %Catchup.Fetcher{
block_fetcher: %Block.Fetcher{
json_rpc_named_arguments: [
transport: _,
transport_options: [http: _, url: url, http_options: _],
variant: _
]
}
},
task: %Task{ref: ref}
} = state
) do
Logger.error(fn ->
"Catchup index stream exited because the archive node endpoint at #{url} is unavailable. Restarting"
end)
send(self(), :catchup_index)
{:noreply, %__MODULE__{state | task: nil}}
end
def handle_info(
{_ref, {:error, :econnrefused}},
%__MODULE__{
fetcher: %Catchup.Fetcher{
block_fetcher: %Block.Fetcher{
json_rpc_named_arguments: [
transport: _,
transport_options: [http: _, url: url, http_options: _],
variant: _
]
}
},
task: nil
} = state
) do
Logger.error(fn ->
"Catchup index stream exited because the archive node endpoint at #{url} is unavailable. Restarting"
end)
send(self(), :catchup_index)
{:noreply, %__MODULE__{state | task: nil}}
end
def handle_info(
{:DOWN, ref, :process, pid, reason},
%__MODULE__{task: %Task{pid: pid, ref: ref}} = state

@ -10,7 +10,11 @@ ifeq ($(SYSTEM), Linux)
HOST=localhost
endif
DB_URL = postgresql://postgres:@$(HOST):5432/explorer?ssl=false
ifdef DATABASE_URL
DB_URL = $(DATABASE_URL)
else
DB_URL = postgresql://postgres:@$(HOST):5432/explorer?ssl=false
endif
BLOCKSCOUT_CONTAINER_PARAMS = -e 'MIX_ENV=prod' \
-e 'DATABASE_URL=$(DB_URL)'
ifeq ($(SYSTEM), Linux)
@ -371,6 +375,12 @@ endif
ifdef COIN_NAME
BLOCKSCOUT_CONTAINER_PARAMS += -e 'COIN_NAME=$(COIN_NAME)'
endif
ifdef INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER=$(INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER)'
endif
ifdef INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=$(INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER)'
endif
HAS_BLOCKSCOUT_IMAGE := $(shell docker images | grep -sw ${DOCKER_IMAGE})
build:
@ -395,6 +405,10 @@ migrate: build postgres
PG_EXIST := $(shell docker ps -a --filter name=${PG_CONTAINER_NAME} | grep ${PG_CONTAINER_NAME})
PG_STARTED := $(shell docker ps --filter name=${PG_CONTAINER_NAME} | grep ${PG_CONTAINER_NAME})
postgres:
ifdef DATABASE_URL
@echo "==> DATABASE_URL of external DB provided. There is no need to start a container for DB."
@$(MAKE) -f $(THIS_FILE) migrate_only
else
ifdef PG_EXIST
@echo "==> Checking PostrgeSQL container"
ifdef PG_STARTED
@ -416,18 +430,37 @@ else
@sleep 1
@$(MAKE) -f $(THIS_FILE) migrate_only
endif
endif
start: build postgres
@echo "==> Starting blockscout"
@docker run --rm --name $(BS_CONTAINER_NAME) \
$(BLOCKSCOUT_CONTAINER_PARAMS) \
-p 4000:4000 \
$(DOCKER_IMAGE) /bin/sh -c "mix do ecto.create, ecto.migrate; mix phx.server"
$(DOCKER_IMAGE) /bin/sh -c "mix phx.server"
BS_STARTED := $(shell docker ps --filter name=${BS_CONTAINER_NAME} | grep ${BS_CONTAINER_NAME})
stop:
ifdef BS_STARTED
@echo "==> Stopping BlockScout container."
@docker stop $(BS_CONTAINER_NAME)
@echo "==> BlockScout container stopped."
else
@echo "==> BlockScout container already stopped before."
endif
ifdef PG_STARTED
@echo "==> Stopping Postgres container."
@docker stop $(PG_CONTAINER_NAME)
@echo "==> Postgres container stopped."
else
@echo "==> Postgres container already stopped before."
endif
run: start
.PHONY: build \
migrate \
start \
stop \
postgres \
run

Loading…
Cancel
Save