mirror of https://gitlab.com/litecord/litecord.git
remove voice websocket fields from configs
- run: remove vws spawn - tests.conftest: rollback to unused_tcp_port fixture
This commit is contained in:
parent
2711924e03
commit
f22a9b92a9
|
|
@ -38,18 +38,12 @@ class Config:
|
|||
# will hit the websocket.
|
||||
# e.g 'gateway.example.com' for reverse proxies.
|
||||
WEBSOCKET_URL = 'localhost:5001'
|
||||
VOICE_WEBSOCKET_URL = 'localhost:5002'
|
||||
|
||||
# Where to host the websocket?
|
||||
# (a local address the server will bind to)
|
||||
WS_HOST = 'localhost'
|
||||
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 = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,18 +46,12 @@ class Config:
|
|||
# will hit the websocket.
|
||||
# e.g 'gateway.example.com' for reverse proxies.
|
||||
WEBSOCKET_URL = 'localhost:5001'
|
||||
VOICE_WEBSOCKET_URL = 'localhost:5003'
|
||||
|
||||
#: Where to host the websocket?
|
||||
# (a local address the server will bind to)
|
||||
WS_HOST = '0.0.0.0'
|
||||
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 is made to prevent client IPs being leaked.
|
||||
MEDIA_PROXY = 'localhost:5002'
|
||||
|
|
|
|||
10
run.py
10
run.py
|
|
@ -72,7 +72,6 @@ from litecord.jobs import JobManager
|
|||
from litecord.voice.manager import VoiceManager
|
||||
|
||||
from litecord.gateway import websocket_handler
|
||||
from litecord.voice.websocket_starter import voice_websocket_handler
|
||||
|
||||
from litecord.utils import LitecordJSONEncoder
|
||||
|
||||
|
|
@ -323,19 +322,14 @@ async def app_before_serving():
|
|||
init_app_managers(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(
|
||||
app.config['WS_HOST'], app.config['WS_PORT'],
|
||||
websocket_handler
|
||||
)
|
||||
|
||||
vws_fut = start_websocket(
|
||||
app.config['VWS_HOST'], app.config['VWS_PORT'],
|
||||
voice_websocket_handler
|
||||
)
|
||||
|
||||
await ws_fut
|
||||
await vws_fut
|
||||
|
||||
|
||||
@app.after_serving
|
||||
|
|
|
|||
|
|
@ -29,30 +29,19 @@ sys.path.append(os.getcwd())
|
|||
|
||||
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')
|
||||
def _test_app(event_loop):
|
||||
def _test_app(unused_tcp_port, event_loop):
|
||||
set_blueprints(main_app)
|
||||
main_app.config['_testing'] = True
|
||||
|
||||
# reassign an unused tcp port for websockets
|
||||
# since the config might give a used one.
|
||||
ws_port, vws_port = _unused_port(), _unused_port()
|
||||
print(ws_port, vws_port)
|
||||
ws_port = unused_tcp_port
|
||||
|
||||
main_app.config['WS_PORT'] = 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
|
||||
event_loop.run_until_complete(main_app.startup())
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue