Files
aitbc/scripts/deployment/production-deploy-part2.sh
aitbc 3897bcbf24
Some checks failed
CLI Tests / test-cli (push) Failing after 4s
Deploy to Testnet / deploy-testnet (push) Successful in 1m40s
Documentation Validation / validate-docs (push) Failing after 12s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Successful in 2m42s
Package Tests / Python package - aitbc-agent-sdk (push) Failing after 34s
Package Tests / Python package - aitbc-core (push) Successful in 27s
Package Tests / Python package - aitbc-crypto (push) Successful in 13s
Package Tests / Python package - aitbc-sdk (push) Successful in 16s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 8s
Package Tests / JavaScript package - aitbc-token (push) Successful in 18s
Python Tests / test-python (push) Failing after 50s
Security Scanning / security-scan (push) Failing after 43s
Multi-Node Stress Testing / stress-test (push) Successful in 12s
Cross-Node Transaction Testing / transaction-test (push) Successful in 9s
refactor: move version to separate module and improve logging
- Created aitbc/_version.py with centralized version definition
- Updated aitbc/__init__.py to import __version__ from _version module
- Updated constants.py to use __version__ for PACKAGE_VERSION
- Replaced print() calls with logger in decorators.py, events.py, queue_manager.py, and state.py
- Added logger initialization using get_logger(__name__) in config.py, decorators.py, events.py, queue_manager.py, and state.py
- Added cli/commands
2026-05-11 20:12:01 +02:00

203 lines
6.7 KiB
Bash
Executable File

#!/bin/bash
# ============================================================================
# AITBC Production Services Deployment - Part 2
# ============================================================================
set -e
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
AITBC_ROOT="${AITBC_ROOT:-/opt/aitbc}"
VENV_DIR="$AITBC_ROOT/venv"
PYTHON_CMD="$VENV_DIR/bin/python"
echo -e "${BLUE}🚀 AITBC PRODUCTION SERVICES DEPLOYMENT - PART 2${NC}"
echo "=============================================="
echo "Deploying production services to aitbc and aitbc1"
echo ""
# Step 3: Deploy to aitbc (localhost)
echo -e "${CYAN}🚀 Step 3: Deploy to aitbc (localhost)${NC}"
echo "======================================"
# Test blockchain service on aitbc
echo "Testing blockchain service on aitbc..."
cd /opt/aitbc
source venv/bin/activate
export NODE_ID=aitbc
python production/services/blockchain.py > /opt/aitbc/production/logs/blockchain/blockchain_test.log 2>&1
if [ $? -eq 0 ]; then
echo "✅ Blockchain service test passed"
else
echo "❌ Blockchain service test failed"
cat /opt/aitbc/production/logs/blockchain/blockchain_test.log
fi
# Start marketplace service on aitbc
echo "Starting marketplace service on aitbc..."
export MARKETPLACE_PORT=8002
nohup python production/services/marketplace.py > /opt/aitbc/production/logs/marketplace/marketplace.log 2>&1 &
MARKETPLACE_PID=$!
echo "✅ Marketplace service started on aitbc (PID: $MARKETPLACE_PID)"
echo "✅ Production services deployed to aitbc"
# Step 4: Deploy to aitbc1 (remote)
echo -e "${CYAN}🚀 Step 4: Deploy to aitbc1 (remote)${NC}"
echo "===================================="
# Copy production setup to aitbc1
echo "Copying production setup to aitbc1..."
scp -r /opt/aitbc/production aitbc1:/opt/aitbc/
scp -r /opt/aitbc/production/services aitbc1:/opt/aitbc/production/
# Install dependencies on aitbc1
echo "Installing dependencies on aitbc1..."
ssh aitbc1 "cd /opt/aitbc && source venv/bin/activate && pip install sqlalchemy psycopg2-binary redis celery fastapi uvicorn pydantic"
# Test blockchain service on aitbc1
echo "Testing blockchain service on aitbc1..."
ssh aitbc1 "cd /opt/aitbc && source venv/bin/activate && export NODE_ID=aitbc1 && python production/services/blockchain.py" > /tmp/aitbc1_blockchain_test.log 2>&1
if [ $? -eq 0 ]; then
echo "✅ Blockchain service test passed on aitbc1"
else
echo "❌ Blockchain service test failed on aitbc1"
cat /tmp/aitbc1_blockchain_test.log
fi
# Start marketplace service on aitbc1
echo "Starting marketplace service on aitbc1..."
ssh aitbc1 "cd /opt/aitbc && source venv/bin/activate && export NODE_ID=aitbc1 && export MARKETPLACE_PORT=8003 && nohup python production/services/marketplace.py > /opt/aitbc/production/logs/marketplace/marketplace_aitbc1.log 2>&1 &"
echo "✅ Production services deployed to aitbc1"
# Step 5: Test Production Services
echo -e "${CYAN}🧪 Step 5: Test Production Services${NC}"
echo "==============================="
sleep 5
# Test aitbc marketplace service
echo "Testing aitbc marketplace service..."
curl -s http://localhost:8002/health | head -10 || echo "aitbc marketplace not responding"
# Test aitbc1 marketplace service
echo "Testing aitbc1 marketplace service..."
ssh aitbc1 "curl -s http://localhost:8003/health" | head -10 || echo "aitbc1 marketplace not responding"
# Test blockchain connectivity between nodes
echo "Testing blockchain connectivity..."
cd /opt/aitbc
source venv/bin/activate
python -c "
import sys
import os
sys.path.insert(0, '/opt/aitbc/production/services')
# Test blockchain on both nodes
for node in ['aitbc', 'aitbc1']:
try:
os.environ['NODE_ID'] = node
from blockchain import ProductionBlockchain
blockchain = ProductionBlockchain(node)
info = blockchain.get_blockchain_info()
print(f'{node}: {info[\"blocks\"]} blocks, {info[\"validators\"]} validators')
# Create test transaction
tx_hash = blockchain.create_transaction(
from_address=f'0xuser_{node}',
to_address='0xuser_other',
amount=50.0,
data={'type': 'test', 'node': node}
)
print(f'{node}: Transaction {tx_hash} created')
except Exception as e:
print(f'{node}: Error - {e}')
"
# Step 6: Production GPU Marketplace Test
echo -e "${CYAN}🖥️ Step 6: Production GPU Marketplace Test${NC}"
echo "========================================"
# Add GPU listing on aitbc
echo "Adding GPU listing on aitbc..."
curl -X POST http://localhost:8002/gpu/listings \
-H "Content-Type: application/json" \
-d '{
"provider": "aitbc",
"gpu_type": "NVIDIA GeForce RTX 4060 Ti",
"memory_gb": 15,
"price_per_hour": 35.0,
"status": "available",
"specs": {
"cuda_cores": 4352,
"memory_bandwidth": "448 GB/s",
"power_consumption": "285W"
}
}' | head -5
# Add GPU listing on aitbc1
echo "Adding GPU listing on aitbc1..."
ssh aitbc1 "curl -X POST http://localhost:8003/gpu/listings \
-H 'Content-Type: application/json' \
-d '{
\"provider\": \"aitbc1\",
\"gpu_type\": \"NVIDIA GeForce RTX 4060 Ti\",
\"memory_gb\": 15,
\"price_per_hour\": 32.0,
\"status\": \"available\",
\"specs\": {
\"cuda_cores\": 4352,
\"memory_bandwidth\": \"448 GB/s\",
\"power_consumption\": \"285W\"
}
}'" | head -5
# Get marketplace stats from both nodes
echo "Getting marketplace stats..."
echo "aitbc stats:"
curl -s http://localhost:8002/stats | head -5
echo "aitbc1 stats:"
ssh aitbc1 "curl -s http://localhost:8003/stats" | head -5
echo ""
echo -e "${GREEN}🎉 PRODUCTION DEPLOYMENT COMPLETED!${NC}"
echo "=================================="
echo ""
echo "✅ Production services deployed to both nodes:"
echo " • aitbc (localhost): Blockchain + Marketplace (port 8002)"
echo " • aitbc1 (remote): Blockchain + Marketplace (port 8003)"
echo ""
echo "✅ Production features:"
echo " • Real database persistence"
echo " • Production logging and monitoring"
echo " • Multi-node coordination"
echo " • GPU marketplace with real hardware"
echo ""
echo "✅ Services tested:"
echo " • Blockchain transactions on both nodes"
echo " • GPU marketplace listings on both nodes"
echo " • Inter-node connectivity"
echo ""
echo -e "${BLUE}🚀 Production system ready for real workloads!${NC}"
echo ""
echo "📊 Service URLs:"
echo " • aitbc marketplace: http://localhost:8002"
echo " • aitbc1 marketplace: http://aitbc1:8003"
echo ""
echo "📋 Logs:"
echo " • Blockchain: /opt/aitbc/production/logs/blockchain/"
echo " • Marketplace: /opt/aitbc/production/logs/marketplace/"