diff --git a/DEV_config.json b/DEV_config.json index 7a2fac4..fa8c24f 100644 --- a/DEV_config.json +++ b/DEV_config.json @@ -1,4 +1,7 @@ { + "info": { + "info":"welcome to steemit.com" + }, "limits": { "blacklist_accounts": [ "non-steemit" @@ -9,10 +12,9 @@ "name": "steemd", "translate_to_appbase": true, "urls": [ - [ - "steemd", - "https://api.steemit.com" - ] + ["appbase", ["https://api.steem.fans","https://api.steemit.com"]], + ["appbase.condenser_api", ["https://api.steem.fans","https://api.steemit.com"]], + ["appbase.condenser_api.get_block", ["https://api.steemit.com","https://api.steem.fans"]] ], "ttls": [ [ diff --git a/docker-compose.yml b/docker-compose.yml index 1d170e3..f618b15 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,28 +1,18 @@ version: "3.3" services: jussi: - restart: "no" + restart: "always" image: "steemit/jussi:latest" ports: - "8080:8080" - - "7777:7777" environment: + JUSSI_UPSTREAM_CONFIG_FILE: /app/config.json JUSSI_REDIS_URL: redis://redis1:6379 - JUSSI_REDIS_READ_REPLICA_URLS: redis://redis2:6379 - JUSSI_STATSD_URL: statsd://statsd:8125 - env_file: .env volumes: - - /Users/muyloco/Dev/steemit/jussi/DEV_config.json:/app/DEV_config.json + - ./config.json:/app/config.json + - ./jussi/:/app/jussi/ redis1: - restart: "no" - image: "redis:3.2" - redis2: - restart: "no" - image: "redis:3.2" - ports: - - "6379:6379" - statsd: - restart: "no" - image: "statsd" - ports: - - "8125:8125/udp" + restart: "always" + image: "redis:latest" + volumes: + - ./redis1:/data diff --git a/jussi/handlers.py b/jussi/handlers.py index fbf28c0..ab43cf6 100644 --- a/jussi/handlers.py +++ b/jussi/handlers.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import ujson import asyncio import concurrent.futures import datetime @@ -45,13 +46,21 @@ async def handle_jsonrpc(http_request: HTTPRequest) -> HTTPResponse: async def healthcheck(http_request: HTTPRequest) -> HTTPResponse: - return response.json({ + health={ 'status': 'OK', 'datetime': datetime.datetime.utcnow().isoformat(), 'source_commit': http_request.app.config.args.source_commit, 'docker_tag': http_request.app.config.args.docker_tag, 'jussi_num': http_request.app.config.last_irreversible_block_num - }) + } + try: + with open(r'./config.json', 'r') as f: + info = ujson.load(f) + info = info["info"] + health.update(info) + except: + pass + return response.json(health) # pylint: disable=protected-access, too-many-locals, no-member, unused-variable diff --git a/jussi/upstream.py b/jussi/upstream.py index e25ff58..b65acda 100644 --- a/jussi/upstream.py +++ b/jussi/upstream.py @@ -12,6 +12,7 @@ import pygtrie import structlog import ujson +import random from .errors import InvalidUpstreamHost from .errors import InvalidUpstreamURL @@ -83,7 +84,10 @@ def __build_trie(self, key): value_key = keys[keys.index(prefix_key) - 1] prefix = item[prefix_key] value = item[value_key] - trie[prefix] = value + if isinstance(value, list): + trie[prefix] = random.choice(value) + else: + trie[prefix] = value return trie @functools.lru_cache(8192)