Files
aitbc/services/marketplace.py
aitbc d72945f20c
Some checks failed
Systemd Sync / sync-systemd (push) Waiting to run
CLI Tests / test-cli (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
API Endpoint Tests / test-api-endpoints (push) Has been cancelled
network: add hub registration, Redis persistence, and federated mesh join protocol
- Change default P2P port from 7070 to 8001 in config and .env.example
- Add redis_url configuration option for hub persistence (default: redis://localhost:6379)
- Implement DNS-based hub registration/unregistration via HTTPS API endpoints
- Add Redis persistence for hub registrations with 1-hour TTL
- Add island join request/response protocol with member list and blockchain credentials
- Add GPU marketplace tracking (offers, bids, providers) in hub manager
- Add
2026-04-13 11:47:34 +02:00

88 lines
2.7 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Marketplace Service for AITBC Production
"""
import os
import sys
import time
import logging
from pathlib import Path
# Add paths
sys.path.insert(0, '/opt/aitbc/apps/marketplace/src')
sys.path.insert(0, '/opt/aitbc/apps/coordinator-api/src')
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__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()