Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add welcome info and Add random node #233

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions DEV_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"info": {
"info":"welcome to steemit.com"
},
"limits": {
"blacklist_accounts": [
"non-steemit"
Expand All @@ -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": [
[
Expand Down
26 changes: 8 additions & 18 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 11 additions & 2 deletions jussi/handlers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import ujson
import asyncio
import concurrent.futures
import datetime
Expand Down Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion jussi/upstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import pygtrie
import structlog
import ujson
import random

from .errors import InvalidUpstreamHost
from .errors import InvalidUpstreamURL
Expand Down Expand Up @@ -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)
Expand Down