Skip to content
Snippets Groups Projects
Commit 574cdd05 authored by Dan Notestein's avatar Dan Notestein
Browse files

Merge branch 'dk-issue-51' into 'develop'

Issue 51

See merge request !70
parents d9dd51eb 7bdd8f28
No related branches found
No related tags found
4 merge requests!456Release candidate v1 24,!230Setup monitoring with pghero,!135Enable postgres monitoring on CI server,!70Issue 51
...@@ -130,3 +130,6 @@ tests/failed_blocks/ ...@@ -130,3 +130,6 @@ tests/failed_blocks/
# pyrest tests # pyrest tests
*.out.json *.out.json
# version.py
version.py
...@@ -36,7 +36,7 @@ before_script: ...@@ -36,7 +36,7 @@ before_script:
hivemind_build: hivemind_build:
stage: build stage: build
script: script:
- pip3 install --user --upgrade pip setuptools - pip3 install --user --upgrade pip setuptools gitpython
- git fetch --tags - git fetch --tags
- git tag -f ci_implicit_tag - git tag -f ci_implicit_tag
- echo $PYTHONUSERBASE - echo $PYTHONUSERBASE
...@@ -71,7 +71,7 @@ hivemind_sync: ...@@ -71,7 +71,7 @@ hivemind_sync:
PYTHONUSERBASE: ./local-site PYTHONUSERBASE: ./local-site
script: script:
- pip3 install --user --upgrade pip setuptools - pip3 install --user --upgrade pip setuptools gitpython
- scripts/ci_sync.sh "$HIVEMIND_DB_NAME" "$HIVEMIND_POSTGRESQL_CONNECTION_STRING" "$HIVEMIND_SOURCE_HIVED_URL" $HIVEMIND_MAX_BLOCK $HIVEMIND_HTTP_PORT - scripts/ci_sync.sh "$HIVEMIND_DB_NAME" "$HIVEMIND_POSTGRESQL_CONNECTION_STRING" "$HIVEMIND_SOURCE_HIVED_URL" $HIVEMIND_MAX_BLOCK $HIVEMIND_HTTP_PORT
artifacts: artifacts:
......
...@@ -16,6 +16,7 @@ aiohttp = "*" ...@@ -16,6 +16,7 @@ aiohttp = "*"
aiopg = "*" aiopg = "*"
"psycopg2-binary" = "*" "psycopg2-binary" = "*"
"diff-match-patch" = "*" "diff-match-patch" = "*"
"gitpython" = "*"
[dev-packages] [dev-packages]
......
...@@ -61,8 +61,13 @@ class Conf(): ...@@ -61,8 +61,13 @@ class Conf():
# configure logger and print config # configure logger and print config
root = logging.getLogger() root = logging.getLogger()
root.setLevel(conf.log_level()) root.setLevel(conf.log_level())
root.info("loaded configuration:\n%s",
_sanitized_conf(parser)) from sys import argv
root.info("Used command line args: %s", " ".join(argv[1:]))
# uncomment for full list of program args
#args_list = ["--" + k + " " + str(v) for k,v in vars(args).items()]
#root.info("Full command line args: %s", " ".join(args_list))
if conf.mode() == 'server': if conf.mode() == 'server':
#DbStats.SLOW_QUERY_MS = 750 #DbStats.SLOW_QUERY_MS = 750
......
...@@ -10,6 +10,7 @@ from hive.server.condenser_api.cursor import get_followers, get_following ...@@ -10,6 +10,7 @@ from hive.server.condenser_api.cursor import get_followers, get_following
from hive.server.bridge_api.cursor import ( from hive.server.bridge_api.cursor import (
pids_by_blog, pids_by_comments, pids_by_feed_with_reblog) pids_by_blog, pids_by_comments, pids_by_feed_with_reblog)
from hive.db.schema import DB_VERSION as SCHEMA_DB_VERSION
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -108,3 +109,20 @@ async def list_account_feed(context, account, limit=10, observer=None, last_post ...@@ -108,3 +109,20 @@ async def list_account_feed(context, account, limit=10, observer=None, last_post
if rby: post['reblogged_by'] = list(rby) if rby: post['reblogged_by'] = list(rby)
return posts return posts
async def get_info(context):
db = context['db']
sql = "SELECT num FROM hive_blocks ORDER BY num DESC LIMIT 1"
database_head_block = await db.query_one(sql)
from hive.version import VERSION, GIT_REVISION
ret = {
"hivemind_version" : VERSION,
"hivemind_git_rev" : GIT_REVISION,
"database_schema_version" : SCHEMA_DB_VERSION,
"database_head_block" : database_head_block
}
return ret
...@@ -27,6 +27,7 @@ from hive.server.bridge_api.support import get_post_header as bridge_api_get_pos ...@@ -27,6 +27,7 @@ from hive.server.bridge_api.support import get_post_header as bridge_api_get_pos
from hive.server.hive_api import community as hive_api_community from hive.server.hive_api import community as hive_api_community
from hive.server.hive_api import notify as hive_api_notify from hive.server.hive_api import notify as hive_api_notify
from hive.server.hive_api import stats as hive_api_stats from hive.server.hive_api import stats as hive_api_stats
from hive.server.hive_api.public import get_info as hive_api_get_info
from hive.server.follow_api import methods as follow_api from hive.server.follow_api import methods as follow_api
from hive.server.tags_api import methods as tags_api from hive.server.tags_api import methods as tags_api
...@@ -62,6 +63,8 @@ def build_methods(): ...@@ -62,6 +63,8 @@ def build_methods():
db_head_state, db_head_state,
)}) )})
methods.add(**{'hive.get_info' : hive_api_get_info})
methods.add(**{'condenser_api.' + method.__name__: method for method in ( methods.add(**{'condenser_api.' + method.__name__: method for method in (
condenser_api.get_followers, condenser_api.get_followers,
condenser_api.get_following, condenser_api.get_following,
...@@ -220,7 +223,24 @@ def run_server(conf): ...@@ -220,7 +223,24 @@ def run_server(conf):
app['db'].close() app['db'].close()
await app['db'].wait_closed() await app['db'].wait_closed()
async def show_info(app):
sql = "SELECT num FROM hive_blocks ORDER BY num DESC LIMIT 1"
database_head_block = await app['db'].query_one(sql)
import pkg_resources
hivemind_version, hivemind_git_rev = pkg_resources.get_distribution("hivemind").version.split("+")
from hive.version import VERSION, GIT_REVISION
log.info("hivemind_version : %s", VERSION)
log.info("hivemind_git_rev : %s", GIT_REVISION)
from hive.db.schema import DB_VERSION as SCHEMA_DB_VERSION
log.info("database_schema_version : %s", SCHEMA_DB_VERSION)
log.info("database_head_block : %s", database_head_block)
app.on_startup.append(init_db) app.on_startup.append(init_db)
app.on_startup.append(show_info)
app.on_cleanup.append(close_db) app.on_cleanup.append(close_db)
async def head_age(request): async def head_age(request):
......
# generated by setup.py
# contents will be overwritten
VERSION = '0.0.1'
GIT_REVISION = '5c0b832'
...@@ -38,6 +38,7 @@ sleep 5 ...@@ -38,6 +38,7 @@ sleep 5
ls -l dist/* ls -l dist/*
rm -rf ./local-site rm -rf ./local-site
mkdir -p `python3 -m site --user-site` mkdir -p `python3 -m site --user-site`
pip3 install --user gitpython
python3 setup.py install --user --force python3 setup.py install --user --force
ln -sf ./local-site/bin/hive $HIVE_NAME ln -sf ./local-site/bin/hive $HIVE_NAME
./$HIVE_NAME -h ./$HIVE_NAME -h
......
...@@ -43,6 +43,7 @@ sleep 5 ...@@ -43,6 +43,7 @@ sleep 5
ls -l dist/* ls -l dist/*
rm -rf ./local-site rm -rf ./local-site
mkdir -p `python3 -m site --user-site` mkdir -p `python3 -m site --user-site`
pip3 install --user gitpython
python3 setup.py install --user --force python3 setup.py install --user --force
ln -sf ./local-site/bin/hive $HIVE_NAME ln -sf ./local-site/bin/hive $HIVE_NAME
./$HIVE_NAME -h ./$HIVE_NAME -h
......
# coding=utf-8 # coding=utf-8
import sys import sys
import os
from setuptools import find_packages from setuptools import find_packages
from setuptools import setup from setuptools import setup
assert sys.version_info[0] == 3 and sys.version_info[1] >= 6, "hive requires Python 3.6 or newer" assert sys.version_info[0] == 3 and sys.version_info[1] >= 6, "hive requires Python 3.6 or newer"
def get_git_version():
from git import Repo
repo = Repo(os.path.abspath("."))
return repo.git.rev_parse('--short', 'HEAD')
VERSION = '0.0.1'
GIT_REVISION = get_git_version()
tests_require = [ tests_require = [
'pytest', 'pytest',
'pytest-cov', 'pytest-cov',
...@@ -17,10 +26,16 @@ tests_require = [ ...@@ -17,10 +26,16 @@ tests_require = [
'yapf', 'yapf',
] ]
with open("hive/version.py", 'w') as version_file:
version_file.write("# generated by setup.py\n")
version_file.write("# contents will be overwritten\n")
version_file.write("VERSION = '{}'\n".format(VERSION))
version_file.write("GIT_REVISION = '{}'\n".format(GIT_REVISION))
# yapf: disable # yapf: disable
setup( setup(
name='hivemind', name='hivemind',
version_format='0.0.1+{gitsha}', version_format=VERSION + "+" + GIT_REVISION,
description='Developer-friendly microservice powering social networks on the Steem blockchain.', description='Developer-friendly microservice powering social networks on the Steem blockchain.',
long_description=open('README.md').read(), long_description=open('README.md').read(),
packages=find_packages(exclude=['scripts']), packages=find_packages(exclude=['scripts']),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment