Add configuration for websocket server

This commit is contained in:
vrde
2017-04-07 10:51:00 +02:00
parent f23faaa65f
commit d260e16f11
4 changed files with 16 additions and 2 deletions

View File

@@ -59,6 +59,10 @@ config = {
'workers': None, # if none, the value will be cpu_count * 2 + 1
'threads': None, # if none, the value will be cpu_count * 2 + 1
},
'wsserver': {
'host': os.environ.get('BIGCHAINDB_WSSERVER_HOST') or 'localhost',
'port': int(os.environ.get('BIGCHAINDB_WSSERVER_PORT', 9985)),
},
'database': _database_map[
os.environ.get('BIGCHAINDB_DATABASE_BACKEND', 'rethinkdb')
],

View File

@@ -96,6 +96,10 @@ def run_configure(args, skip_if_exists=False):
val = conf['server'][key]
conf['server'][key] = input_on_stderr('API Server {}? (default `{}`): '.format(key, val), val)
for key in ('host', 'port'):
val = conf['wsserver'][key]
conf['wsserver'][key] = input_on_stderr('WebSocket Server {}? (default `{}`): '.format(key, val), val)
for key in database_keys:
val = conf['database'][key]
conf['database'][key] = input_on_stderr('Database {}? (default `{}`): '.format(key, val), val)

View File

@@ -5,6 +5,9 @@ import logging
from flask import jsonify, request
from bigchaindb import config
logger = logging.getLogger(__name__)
@@ -25,4 +28,4 @@ def base_url():
def base_ws_uri():
"""Base websocket uri."""
return 'ws://localhost:9985/'
return 'ws://{host}:{port}/'.format(**config['wsserver'])

View File

@@ -20,6 +20,7 @@ from uuid import uuid4
import aiohttp
from aiohttp import web
from bigchaindb import config
from bigchaindb.events import EventTypes
@@ -167,4 +168,6 @@ def start(sync_event_source, loop=None):
bridge.start()
app = init_app(event_source, loop=loop)
aiohttp.web.run_app(app, port=9985)
aiohttp.web.run_app(app,
host=config['wsserver']['host'],
port=config['wsserver']['port'])