Consolidate service scripts into apps directories
- Move blockchain scripts to apps/blockchain-node/scripts/ - Move marketplace scripts to apps/marketplace/scripts/ - Move agent daemon to apps/agent-coordinator/scripts/ - Move monitor to apps/monitor/ - Update systemd service files to point to new locations - Update internal path references in moved scripts - Remove empty /opt/aitbc/services directory
This commit is contained in:
78
apps/marketplace/scripts/gpu_marketplace_launcher.py
Executable file
78
apps/marketplace/scripts/gpu_marketplace_launcher.py
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
GPU Marketplace Launcher for AITBC Production
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def main():
|
||||
"""Main GPU marketplace launcher function"""
|
||||
logger.info("Starting AITBC GPU Marketplace Launcher")
|
||||
|
||||
try:
|
||||
# Set environment variables
|
||||
os.environ.setdefault('PYTHONPATH', '/opt/aitbc/apps/marketplace/scripts:/opt/aitbc/apps/marketplace/src:/opt/aitbc/apps/coordinator-api/src')
|
||||
|
||||
# Try to run the GPU marketplace service
|
||||
logger.info("Launching GPU marketplace service")
|
||||
|
||||
# Check if the main marketplace service exists
|
||||
marketplace_path = '/opt/aitbc/apps/marketplace/scripts/marketplace.py'
|
||||
if os.path.exists(marketplace_path):
|
||||
logger.info("Found marketplace service, launching...")
|
||||
subprocess.run([
|
||||
'/opt/aitbc/venv/bin/python',
|
||||
marketplace_path
|
||||
], check=True)
|
||||
else:
|
||||
logger.error(f"Marketplace service not found at {marketplace_path}")
|
||||
# Fallback to simple service
|
||||
fallback_service()
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(f"GPU marketplace service failed with exit code {e.returncode}: {e}")
|
||||
logger.info("Starting fallback GPU marketplace service")
|
||||
fallback_service()
|
||||
except (FileNotFoundError, PermissionError) as e:
|
||||
logger.error(f"Cannot launch GPU marketplace service: {type(e).__name__}: {e}")
|
||||
logger.info("Starting fallback GPU marketplace service")
|
||||
fallback_service()
|
||||
except Exception as e:
|
||||
logger.error(f"Unexpected error launching GPU marketplace: {type(e).__name__}: {e}")
|
||||
logger.info("Starting fallback GPU marketplace service")
|
||||
fallback_service()
|
||||
|
||||
def fallback_service():
|
||||
"""Fallback GPU marketplace service"""
|
||||
logger.info("Starting fallback GPU marketplace service")
|
||||
|
||||
try:
|
||||
# Simple GPU marketplace heartbeat
|
||||
import time
|
||||
|
||||
while True:
|
||||
logger.info("GPU Marketplace service heartbeat - active")
|
||||
time.sleep(30)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
logger.info("GPU Marketplace service stopped by user")
|
||||
except (OSError, IOError) as e:
|
||||
logger.error(f"System error in fallback service: {type(e).__name__}: {e}")
|
||||
time.sleep(5)
|
||||
except Exception as e:
|
||||
logger.error(f"Unexpected error in fallback service: {type(e).__name__}: {e}")
|
||||
time.sleep(5)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user