Robert Brennan cac3b6d7f7
Refactor listen.py (#5281)
Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>
2024-11-26 17:57:24 +00:00

29 lines
728 B
Python

import os
import socketio
from dotenv import load_dotenv
from openhands.core.config import load_app_config
from openhands.server.session import SessionManager
from openhands.storage import get_file_store
load_dotenv()
config = load_app_config()
file_store = get_file_store(config.file_store, config.file_store_path)
client_manager = None
redis_host = os.environ.get('REDIS_HOST')
if redis_host:
client_manager = socketio.AsyncRedisManager(
f'redis://{redis_host}',
redis_options={'password': os.environ.get('REDIS_PASSWORD')},
)
sio = socketio.AsyncServer(
async_mode='asgi', cors_allowed_origins='*', client_manager=client_manager
)
session_manager = SessionManager(sio, config, file_store)