Spaces:
Sleeping
Sleeping
File size: 1,848 Bytes
a4fc4ec | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | """
Configuration Module for SyncMaster
إعدادات التطبيق الأساسية
"""
import os
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
class AppConfig:
"""Configuration class for SyncMaster application"""
# Server settings
STREAMLIT_PORT = int(os.getenv('STREAMLIT_PORT', 5050))
RECORDER_PORT = int(os.getenv('RECORDER_PORT', 5001))
# Development vs Production
IS_PRODUCTION = os.getenv('SPACE_ID') is not None or os.getenv('RAILWAY_ENVIRONMENT') is not None
# Host settings
if IS_PRODUCTION:
STREAMLIT_HOST = "0.0.0.0"
RECORDER_HOST = "0.0.0.0"
else:
STREAMLIT_HOST = "localhost"
RECORDER_HOST = "localhost"
# Integration settings
USE_INTEGRATED_SERVER = IS_PRODUCTION or os.getenv('USE_INTEGRATED_SERVER', 'true').lower() == 'true'
# Logging
LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO')
@classmethod
def get_streamlit_url(cls):
"""Get the Streamlit application URL"""
return f"http://{cls.STREAMLIT_HOST}:{cls.STREAMLIT_PORT}"
@classmethod
def get_recorder_url(cls):
"""Get the recorder server URL"""
return f"http://{cls.RECORDER_HOST}:{cls.RECORDER_PORT}"
@classmethod
def log_config(cls):
"""Log current configuration"""
logging.info("📋 SyncMaster Configuration:")
logging.info(f" • Production Mode: {cls.IS_PRODUCTION}")
logging.info(f" • Integrated Server: {cls.USE_INTEGRATED_SERVER}")
logging.info(f" • Streamlit: {cls.get_streamlit_url()}")
logging.info(f" • Recorder: {cls.get_recorder_url()}")
# Initialize configuration
config = AppConfig()
if __name__ == "__main__":
config.log_config()
|