- Migrate 3 files from logging to aitbc.get_logger - scripts/real_marketplace_launcher.py, scripts/marketplace.py, scripts/gpu_marketplace_launcher.py - Remove logging.basicConfig() from all files
84 lines
2.6 KiB
Python
Executable File
84 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Marketplace Service for AITBC Production
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
from aitbc import get_logger
|
|
|
|
# Add paths
|
|
sys.path.insert(0, '/opt/aitbc/apps/marketplace/src')
|
|
sys.path.insert(0, '/opt/aitbc/apps/coordinator-api/src')
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
def main():
|
|
"""Main marketplace service function"""
|
|
logger.info("Starting AITBC Marketplace Service")
|
|
|
|
try:
|
|
# Try to import and run the actual marketplace service
|
|
from production.services.marketplace import app
|
|
logger.info("Successfully imported marketplace app")
|
|
|
|
# Run the marketplace service
|
|
import uvicorn
|
|
uvicorn.run(app, host="0.0.0.0", port=8007)
|
|
|
|
except ImportError as e:
|
|
logger.error(f"Failed to import marketplace app: {e}")
|
|
logger.info("Trying alternative marketplace import...")
|
|
|
|
try:
|
|
# Try the unified marketplace
|
|
from production.services.unified_marketplace import app
|
|
logger.info("Successfully imported unified marketplace app")
|
|
|
|
import uvicorn
|
|
uvicorn.run(app, host="0.0.0.0", port=8007)
|
|
|
|
except ImportError as e2:
|
|
logger.error(f"Failed to import unified marketplace: {e2}")
|
|
logger.info("Starting simple marketplace heartbeat service")
|
|
heartbeat_service()
|
|
|
|
except Exception as e:
|
|
logger.error(f"Error starting marketplace service: {e}")
|
|
heartbeat_service()
|
|
|
|
def heartbeat_service():
|
|
"""Simple heartbeat service for marketplace"""
|
|
logger.info("Starting marketplace heartbeat service")
|
|
|
|
try:
|
|
# Create a simple FastAPI app for health checks
|
|
from fastapi import FastAPI
|
|
import uvicorn
|
|
|
|
app = FastAPI(title="AITBC Marketplace Service")
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "healthy", "service": "marketplace", "message": "Marketplace service running"}
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"service": "marketplace", "status": "running", "endpoints": ["/health", "/"]}
|
|
|
|
logger.info("Starting simple marketplace API on port 8007")
|
|
uvicorn.run(app, host="0.0.0.0", port=8007)
|
|
|
|
except ImportError:
|
|
# Fallback to simple heartbeat
|
|
logger.info("FastAPI not available, using simple heartbeat")
|
|
while True:
|
|
logger.info("Marketplace service heartbeat - active")
|
|
time.sleep(30)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|