remove voice websocket fields from configs

- run: remove vws spawn
 - tests.conftest: rollback to unused_tcp_port fixture
This commit is contained in:
Luna 2019-03-01 04:39:12 -03:00
parent 2711924e03
commit f22a9b92a9
4 changed files with 4 additions and 33 deletions

View File

@ -38,18 +38,12 @@ class Config:
# will hit the websocket. # will hit the websocket.
# e.g 'gateway.example.com' for reverse proxies. # e.g 'gateway.example.com' for reverse proxies.
WEBSOCKET_URL = 'localhost:5001' WEBSOCKET_URL = 'localhost:5001'
VOICE_WEBSOCKET_URL = 'localhost:5002'
# Where to host the websocket? # Where to host the websocket?
# (a local address the server will bind to) # (a local address the server will bind to)
WS_HOST = 'localhost' WS_HOST = 'localhost'
WS_PORT = 5001 WS_PORT = 5001
#: Where to host the VOICE websocket?
# (a local address the server will bind to)
VWS_HOST = 'localhost'
VWS_PORT = 5003
# Postgres credentials # Postgres credentials
POSTGRES = {} POSTGRES = {}

View File

@ -46,18 +46,12 @@ class Config:
# will hit the websocket. # will hit the websocket.
# e.g 'gateway.example.com' for reverse proxies. # e.g 'gateway.example.com' for reverse proxies.
WEBSOCKET_URL = 'localhost:5001' WEBSOCKET_URL = 'localhost:5001'
VOICE_WEBSOCKET_URL = 'localhost:5003'
#: Where to host the websocket? #: Where to host the websocket?
# (a local address the server will bind to) # (a local address the server will bind to)
WS_HOST = '0.0.0.0' WS_HOST = '0.0.0.0'
WS_PORT = 5001 WS_PORT = 5001
#: Where to host the VOICE websocket?
# (a local address the server will bind to)
VWS_HOST = 'localhost'
VWS_PORT = 5003
#: Mediaproxy URL on the internet #: Mediaproxy URL on the internet
# mediaproxy is made to prevent client IPs being leaked. # mediaproxy is made to prevent client IPs being leaked.
MEDIA_PROXY = 'localhost:5002' MEDIA_PROXY = 'localhost:5002'

10
run.py
View File

@ -72,7 +72,6 @@ from litecord.jobs import JobManager
from litecord.voice.manager import VoiceManager from litecord.voice.manager import VoiceManager
from litecord.gateway import websocket_handler from litecord.gateway import websocket_handler
from litecord.voice.websocket_starter import voice_websocket_handler
from litecord.utils import LitecordJSONEncoder from litecord.utils import LitecordJSONEncoder
@ -323,19 +322,14 @@ async def app_before_serving():
init_app_managers(app) init_app_managers(app)
await post_app_start(app) await post_app_start(app)
# start gateway websocket and voice websocket # start gateway websocket
# voice websocket is handled by the voice server
ws_fut = start_websocket( ws_fut = start_websocket(
app.config['WS_HOST'], app.config['WS_PORT'], app.config['WS_HOST'], app.config['WS_PORT'],
websocket_handler websocket_handler
) )
vws_fut = start_websocket(
app.config['VWS_HOST'], app.config['VWS_PORT'],
voice_websocket_handler
)
await ws_fut await ws_fut
await vws_fut
@app.after_serving @app.after_serving

View File

@ -29,30 +29,19 @@ sys.path.append(os.getcwd())
from run import app as main_app, set_blueprints from run import app as main_app, set_blueprints
# pytest-sanic's unused_tcp_port can't be called twice since
# pytest fixtures etc etc.
def _unused_port():
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.bind(('127.0.0.1', 0))
return sock.getsockname()[1]
@pytest.fixture(name='app') @pytest.fixture(name='app')
def _test_app(event_loop): def _test_app(unused_tcp_port, event_loop):
set_blueprints(main_app) set_blueprints(main_app)
main_app.config['_testing'] = True main_app.config['_testing'] = True
# reassign an unused tcp port for websockets # reassign an unused tcp port for websockets
# since the config might give a used one. # since the config might give a used one.
ws_port, vws_port = _unused_port(), _unused_port() ws_port = unused_tcp_port
print(ws_port, vws_port)
main_app.config['WS_PORT'] = ws_port main_app.config['WS_PORT'] = ws_port
main_app.config['WEBSOCKET_URL'] = f'localhost:{ws_port}' main_app.config['WEBSOCKET_URL'] = f'localhost:{ws_port}'
main_app.config['VWS_PORT'] = vws_port
main_app.config['VOICE_WEBSOCKET_URL'] = f'localhost:{vws_port}'
# make sure we're calling the before_serving hooks # make sure we're calling the before_serving hooks
event_loop.run_until_complete(main_app.startup()) event_loop.run_until_complete(main_app.startup())