mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Add configuration for websocket server
This commit is contained in:
@@ -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')
|
||||
],
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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'])
|
||||
|
||||
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user