d10g commited on
Commit
e6a485e
·
1 Parent(s): cbc256d

Simplified CLI launch

Browse files
Files changed (1) hide show
  1. reachy_f1_commentator/main.py +3 -57
reachy_f1_commentator/main.py CHANGED
@@ -1031,62 +1031,8 @@ def save_config(config: dict) -> bool:
1031
  # ============================================================================
1032
 
1033
  if __name__ == "__main__":
1034
- """
1035
- Run the app in standalone mode for development/testing.
1036
-
1037
- This allows running the app without the Reachy Mini framework:
1038
- python -m reachy_f1_commentator.main
1039
-
1040
- The app will auto-detect and connect to Reachy if available.
1041
- """
1042
- import uvicorn
1043
- from fastapi import FastAPI
1044
-
1045
- logger.info("=" * 60)
1046
- logger.info("Starting Reachy F1 Commentator in standalone mode")
1047
- logger.info("=" * 60)
1048
-
1049
- # Initialize app instance
1050
- commentator = ReachyF1Commentator()
1051
-
1052
- # Try to connect to Reachy if running on Reachy hardware
1053
  try:
1054
- from reachy_mini import ReachyMini
1055
- logger.info("Attempting to connect to Reachy Mini...")
1056
- reachy = ReachyMini()
1057
- commentator.reachy_mini_instance = reachy
1058
- logger.info("✅ Connected to Reachy Mini - audio playback enabled")
1059
- except ImportError:
1060
- logger.info("⚠️ Reachy Mini SDK not installed - running without Reachy")
1061
- logger.info(" Audio playback will be disabled (text commentary only)")
1062
- logger.info(" Install with: pip install reachy-mini")
1063
- except Exception as e:
1064
- logger.warning(f"⚠️ Could not connect to Reachy Mini: {e}")
1065
- logger.info(" Running without Reachy - audio playback disabled")
1066
- logger.info(" This is normal for development/testing")
1067
-
1068
- # Create a standalone FastAPI app for development
1069
- standalone_app = FastAPI(title="Reachy F1 Commentator API (Standalone)")
1070
-
1071
- # Manually set up the app's settings_app to use our standalone app
1072
- commentator.settings_app = standalone_app
1073
-
1074
- # Setup API routes
1075
- commentator._setup_api_routes()
1076
-
1077
- # Run FastAPI server on port 8080 (port 8000 is used by Reachy)
1078
- logger.info("")
1079
- logger.info("Starting web server on http://localhost:8080")
1080
- logger.info("Open http://localhost:8080 in your browser")
1081
- logger.info("=" * 60)
1082
-
1083
- try:
1084
- uvicorn.run(
1085
- standalone_app,
1086
- host="0.0.0.0",
1087
- port=8080,
1088
- log_level="info"
1089
- )
1090
  except KeyboardInterrupt:
1091
- logger.info("Shutting down...")
1092
- commentator._cleanup()
 
1031
  # ============================================================================
1032
 
1033
  if __name__ == "__main__":
1034
+ app = ReachyF1Commentator()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1035
  try:
1036
+ app.wrapped_run()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1037
  except KeyboardInterrupt:
1038
+ app.stop()