docker compose update

This commit is contained in:
Victor Shyba 2021-02-11 21:45:41 -03:00
parent 0a194b5b01
commit e12fab90d1
4 changed files with 59 additions and 38 deletions

View file

@ -6,7 +6,6 @@ install:
--global-option=fetch \ --global-option=fetch \
--global-option=--version --global-option=3.30.1 --global-option=--all \ --global-option=--version --global-option=3.30.1 --global-option=--all \
--global-option=build --global-option=--enable --global-option=fts5 --global-option=build --global-option=--enable --global-option=fts5
python -m pip install elasticsearch[async]
pip install -e . pip install -e .
tools: tools:

View file

@ -13,6 +13,8 @@ RUN apt-get update && \
wget \ wget \
tar unzip \ tar unzip \
build-essential \ build-essential \
pkg-config \
libleveldb-dev \
python3 \ python3 \
python3-dev \ python3-dev \
python3-pip \ python3-pip \

View file

@ -3,6 +3,7 @@ version: "3"
volumes: volumes:
lbrycrd: lbrycrd:
wallet_server: wallet_server:
es01:
services: services:
lbrycrd: lbrycrd:
@ -34,3 +35,18 @@ services:
# Curently not snapshot provided # Curently not snapshot provided
# - SNAPSHOT_URL=${WALLET_SERVER_SNAPSHOT_URL-https://lbry.com/snapshot/wallet} # - SNAPSHOT_URL=${WALLET_SERVER_SNAPSHOT_URL-https://lbry.com/snapshot/wallet}
- DAEMON_URL=http://lbry:lbry@lbrycrd:9245 - DAEMON_URL=http://lbry:lbry@lbrycrd:9245
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.11.0
container_name: es01
environment:
- node.name=es01
- discovery.type=single-node
- bootstrap.memory_lock=true
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es01:/usr/share/elasticsearch/data
ports:
- 127.0.0.1:9200:9200

View file

@ -5,7 +5,7 @@ from decimal import Decimal
from operator import itemgetter from operator import itemgetter
from typing import Optional, List, Iterable from typing import Optional, List, Iterable
from elasticsearch import AsyncElasticsearch, NotFoundError from elasticsearch import AsyncElasticsearch, NotFoundError, ConnectionError
from elasticsearch.helpers import async_bulk from elasticsearch.helpers import async_bulk
from lbry.crypto.base58 import Base58 from lbry.crypto.base58 import Base58
@ -14,6 +14,7 @@ from lbry.schema.result import Outputs, Censor
from lbry.schema.tags import clean_tags from lbry.schema.tags import clean_tags
from lbry.schema.url import URL, normalize_name from lbry.schema.url import URL, normalize_name
from lbry.wallet.server.db.common import CLAIM_TYPES, STREAM_TYPES from lbry.wallet.server.db.common import CLAIM_TYPES, STREAM_TYPES
from lbry.wallet.server.util import class_logger
class SearchIndex: class SearchIndex:
@ -21,14 +22,19 @@ class SearchIndex:
self.client: Optional[AsyncElasticsearch] = None self.client: Optional[AsyncElasticsearch] = None
self.index = index_prefix + 'claims' self.index = index_prefix + 'claims'
self.sync_timeout = 600 # wont hit that 99% of the time, but can hit on a fresh import self.sync_timeout = 600 # wont hit that 99% of the time, but can hit on a fresh import
self.logger = class_logger(__name__, self.__class__.__name__)
async def start(self): async def start(self):
if self.client: if self.client:
return return
self.client = AsyncElasticsearch(timeout=self.sync_timeout) self.client = AsyncElasticsearch(timeout=self.sync_timeout)
while True:
try: try:
if await self.client.indices.exists(self.index): await self.client.cluster.health(wait_for_status='yellow')
return break
except ConnectionError:
self.logger.warning("Failed to connect to Elasticsearch. Waiting for it!")
await asyncio.sleep(1)
await self.client.indices.create( await self.client.indices.create(
self.index, self.index,
{ {
@ -62,10 +68,8 @@ class SearchIndex:
"trending_mixed": {"type": "float"}, "trending_mixed": {"type": "float"},
} }
} }
} }, ignore=400
) )
except Exception as e:
raise
def stop(self): def stop(self):
client = self.client client = self.client