refactor: clean up configuration and add production infrastructure

- Add .aitbc.yaml configuration file with test values
- Simplify .gitignore by removing merge conflicts and redundant entries
- Reorganize .gitignore sections for better clarity
- Set chain_id and proposer_id to empty strings in config.py (require explicit configuration)
- Add production Helm values configuration
- Add production nginx configuration
- Update environment variable handling in chain settings
This commit is contained in:
2026-03-19 12:59:34 +01:00
committed by aitbc
parent 5f2ab48b9a
commit b4b5a57390
111 changed files with 13106 additions and 346 deletions

View File

@@ -0,0 +1,72 @@
#!/bin/bash
# Check what's running in the aitbc container
echo "🔍 Checking AITBC Container Status"
echo "================================="
# First, let's see if we can access the container
if ! groups | grep -q incus; then
echo "❌ You're not in the incus group!"
echo "Run: sudo usermod -aG incus \$USER"
echo "Then log out and log back in"
exit 1
fi
echo "📋 Container Info:"
incus list | grep aitbc
echo ""
echo "🔧 Services in container:"
incus exec aitbc -- ps aux | grep -E "(uvicorn|python)" | grep -v grep || echo "No services running"
echo ""
echo "🌐 Ports listening in container:"
incus exec aitbc -- ss -tlnp | grep -E "(8000|9080|3001|3002)" || echo "No ports listening"
echo ""
echo "📁 Nginx status:"
incus exec aitbc -- systemctl status nginx --no-pager -l | head -20
echo ""
echo "🔍 Nginx config test:"
incus exec aitbc -- nginx -t
echo ""
echo "📝 Nginx sites enabled:"
incus exec aitbc -- ls -la /etc/nginx/sites-enabled/
echo ""
echo "🚀 Starting services if needed..."
# Start the services
incus exec aitbc -- bash -c "
cd /home/oib/aitbc
pkill -f uvicorn 2>/dev/null || true
pkill -f server.py 2>/dev/null || true
# Start blockchain node
cd apps/blockchain-node
source ../../.venv/bin/activate
python -m uvicorn aitbc_chain.app:app --host 0.0.0.0 --port 9080 &
# Start coordinator API
cd ../coordinator-api
source ../../.venv/bin/activate
python -m uvicorn src.app.main:app --host 0.0.0.0 --port 8000 &
# Start marketplace UI
cd ../marketplace-ui
python server.py --port 3001 &
# Start trade exchange
cd ../trade-exchange
python server.py --port 3002 &
sleep 3
echo 'Services started!'
"
echo ""
echo "✅ Done! Check services:"
echo "incus exec aitbc -- ps aux | grep uvicorn"

View File

@@ -0,0 +1,65 @@
#!/bin/bash
# Diagnose AITBC services
echo "🔍 Diagnosing AITBC Services"
echo "=========================="
echo ""
# Check local services
echo "📋 Local Services:"
echo "Port 8000 (Coordinator API):"
lsof -i :8000 2>/dev/null || echo " ❌ Not running"
echo "Port 9080 (Blockchain Node):"
lsof -i :9080 2>/dev/null || echo " ❌ Not running"
echo "Port 3001 (Marketplace UI):"
lsof -i :3001 2>/dev/null || echo " ❌ Not running"
echo "Port 3002 (Trade Exchange):"
lsof -i :3002 2>/dev/null || echo " ❌ Not running"
echo ""
echo "🌐 Testing Endpoints:"
# Test local endpoints
echo "Local API Health:"
curl -s http://127.0.0.1:8000/v1/health 2>/dev/null && echo " ✅ OK" || echo " ❌ Failed"
echo "Local Blockchain:"
curl -s http://127.0.0.1:9080/rpc/head 2>/dev/null | head -c 50 && echo "..." || echo " ❌ Failed"
echo "Local Admin:"
curl -s http://127.0.0.1:8000/v1/admin/stats 2>/dev/null | head -c 50 && echo "..." || echo " ❌ Failed"
echo ""
echo "🌐 Remote Endpoints (via domain):"
echo "Domain API Health:"
curl -s https://aitbc.bubuit.net/health 2>/dev/null && echo " ✅ OK" || echo " ❌ Failed"
echo "Domain Admin:"
curl -s https://aitbc.bubuit.net/admin/stats 2>/dev/null | head -c 50 && echo "..." || echo " ❌ Failed"
echo ""
echo "🔧 Fixing common issues..."
# Stop any conflicting services
echo "Stopping local services..."
sudo fuser -k 8000/tcp 2>/dev/null || true
sudo fuser -k 9080/tcp 2>/dev/null || true
sudo fuser -k 3001/tcp 2>/dev/null || true
sudo fuser -k 3002/tcp 2>/dev/null || true
echo ""
echo "📝 Instructions:"
echo "1. Make sure you're in the incus group: sudo usermod -aG incus \$USER"
echo "2. Log out and log back in"
echo "3. Run: incus exec aitbc -- bash"
echo "4. Inside container, run: /home/oib/start_aitbc.sh"
echo "5. Check services: ps aux | grep uvicorn"
echo ""
echo "If services are running in container but not accessible:"
echo "1. Check port forwarding to 10.1.223.93"
echo "2. Check nginx config in container"
echo "3. Check firewall rules"

58
scripts/service/fix-services.sh Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/bash
# Quick fix to start AITBC services in container
echo "🔧 Starting AITBC Services in Container"
echo "====================================="
# First, let's manually start the services
echo "1. Starting Coordinator API..."
cd /home/oib/windsurf/aitbc/apps/coordinator-api
source ../../.venv/bin/activate 2>/dev/null || source .venv/bin/activate
python -m uvicorn src.app.main:app --host 0.0.0.0 --port 8000 &
COORD_PID=$!
echo "2. Starting Blockchain Node..."
cd ../blockchain-node
python -m uvicorn aitbc_chain.app:app --host 0.0.0.0 --port 9080 &
NODE_PID=$!
echo "3. Starting Marketplace UI..."
cd ../marketplace-ui
python server.py --port 3001 &
MARKET_PID=$!
echo "4. Starting Trade Exchange..."
cd ../trade-exchange
python server.py --port 3002 &
EXCHANGE_PID=$!
echo ""
echo "✅ Services started!"
echo "Coordinator API: http://127.0.0.1:8000"
echo "Blockchain: http://127.0.0.1:9080"
echo "Marketplace: http://127.0.0.1:3001"
echo "Exchange: http://127.0.0.1:3002"
echo ""
echo "PIDs:"
echo "Coordinator: $COORD_PID"
echo "Blockchain: $NODE_PID"
echo "Marketplace: $MARKET_PID"
echo "Exchange: $EXCHANGE_PID"
echo ""
echo "To stop: kill $COORD_PID $NODE_PID $MARKET_PID $EXCHANGE_PID"
# Wait a bit for services to start
sleep 3
# Test endpoints
echo ""
echo "🧪 Testing endpoints:"
echo "API Health:"
curl -s http://127.0.0.1:8000/v1/health | head -c 100
echo -e "\n\nAdmin Stats:"
curl -s http://127.0.0.1:8000/v1/admin/stats -H "X-Api-Key: ${ADMIN_API_KEY}" | head -c 100
echo -e "\n\nMarketplace Offers:"
curl -s http://127.0.0.1:8000/v1/marketplace/offers | head -c 100

View File

@@ -0,0 +1,129 @@
#!/bin/bash
# Run AITBC services locally for domain access
set -e
echo "🚀 Starting AITBC Services for Domain Access"
echo "=========================================="
# Kill any existing services
echo "Cleaning up existing services..."
sudo fuser -k 8000/tcp 2>/dev/null || true
sudo fuser -k 9080/tcp 2>/dev/null || true
sudo fuser -k 3001/tcp 2>/dev/null || true
sudo fuser -k 3002/tcp 2>/dev/null || true
pkill -f "uvicorn.*aitbc" 2>/dev/null || true
pkill -f "server.py" 2>/dev/null || true
# Wait for ports to be free
sleep 2
# Create logs directory
mkdir -p logs
echo ""
echo "📦 Starting Services..."
# Start Coordinator API
echo "1. Starting Coordinator API (port 8000)..."
cd apps/coordinator-api
source ../.venv/bin/activate 2>/dev/null || python -m venv ../.venv && source ../.venv/bin/activate
pip install -q -e . 2>/dev/null || true
nohup python -m uvicorn src.app.main:app --host 0.0.0.0 --port 8000 > ../../logs/api.log 2>&1 &
API_PID=$!
echo " PID: $API_PID"
# Start Blockchain Node
echo "2. Starting Blockchain Node (port 9080)..."
cd ../blockchain-node
nohup python -m uvicorn aitbc_chain.app:app --host 0.0.0.0 --port 9080 > ../../logs/blockchain.log 2>&1 &
NODE_PID=$!
echo " PID: $NODE_PID"
# Start Marketplace UI
echo "3. Starting Marketplace UI (port 3001)..."
cd ../marketplace-ui
nohup python server.py --port 3001 > ../../logs/marketplace.log 2>&1 &
MARKET_PID=$!
echo " PID: $MARKET_PID"
# Start Trade Exchange
echo "4. Starting Trade Exchange (port 3002)..."
cd ../trade-exchange
nohup python server.py --port 3002 > ../../logs/exchange.log 2>&1 &
EXCHANGE_PID=$!
echo " PID: $EXCHANGE_PID"
# Save PIDs for cleanup
echo "$API_PID $NODE_PID $MARKET_PID $EXCHANGE_PID" > ../.service_pids
cd ..
# Wait for services to start
echo ""
echo "⏳ Waiting for services to initialize..."
sleep 5
# Test services
echo ""
echo "🧪 Testing Services..."
echo -n "API Health: "
if curl -s http://127.0.0.1:8000/v1/health > /dev/null; then
echo "✅ OK"
else
echo "❌ Failed"
fi
echo -n "Admin API: "
if curl -s http://127.0.0.1:8000/v1/admin/stats -H "X-Api-Key: ${ADMIN_API_KEY}" > /dev/null; then
echo "✅ OK"
else
echo "❌ Failed"
fi
echo -n "Blockchain: "
if curl -s http://127.0.0.1:9080/rpc/head > /dev/null; then
echo "✅ OK"
else
echo "❌ Failed"
fi
echo -n "Marketplace: "
if curl -s http://127.0.0.1:3001 > /dev/null; then
echo "✅ OK"
else
echo "❌ Failed"
fi
echo -n "Exchange: "
if curl -s http://127.0.0.1:3002 > /dev/null; then
echo "✅ OK"
else
echo "❌ Failed"
fi
echo ""
echo "✅ All services started!"
echo ""
echo "📋 Local URLs:"
echo " API: http://127.0.0.1:8000/v1"
echo " RPC: http://127.0.0.1:9080/rpc"
echo " Marketplace: http://127.0.0.1:3001"
echo " Exchange: http://127.0.0.1:3002"
echo ""
echo "🌐 Domain URLs (if nginx is configured):"
echo " API: https://aitbc.bubuit.net/api"
echo " Admin: https://aitbc.bubuit.net/admin"
echo " RPC: https://aitbc.bubuit.net/rpc"
echo " Marketplace: https://aitbc.bubuit.net/Marketplace"
echo " Exchange: https://aitbc.bubuit.net/Exchange"
echo ""
echo "📝 Logs: ./logs/"
echo "🛑 Stop services: ./stop-services.sh"
echo ""
echo "Press Ctrl+C to stop monitoring (services will keep running)"
# Monitor logs
tail -f logs/*.log

View File

@@ -0,0 +1,40 @@
#!/bin/bash
# Download production assets locally
echo "Setting up production assets..."
# Create assets directory
mkdir -p /home/oib/windsurf/aitbc/assets/{css,js,icons}
# Download Tailwind CSS (production build)
echo "Downloading Tailwind CSS..."
curl -L https://unpkg.com/tailwindcss@3.4.0/lib/tailwind.js -o /home/oib/windsurf/aitbc/assets/js/tailwind.js
# Download Axios
echo "Downloading Axios..."
curl -L https://unpkg.com/axios@1.6.2/dist/axios.min.js -o /home/oib/windsurf/aitbc/assets/js/axios.min.js
# Download Lucide icons
echo "Downloading Lucide..."
curl -L https://unpkg.com/lucide@latest/dist/umd/lucide.js -o /home/oib/windsurf/aitbc/assets/js/lucide.js
# Create a custom Tailwind build with only used classes
cat > /home/oib/windsurf/aitbc/assets/tailwind.config.js << 'EOF'
module.exports = {
content: [
"./apps/trade-exchange/index.html",
"./apps/marketplace-ui/index.html"
],
darkMode: 'class',
theme: {
extend: {},
},
plugins: [],
}
EOF
echo "Assets downloaded to /home/oib/windsurf/aitbc/assets/"
echo "Update your HTML files to use local paths:"
echo " - /assets/js/tailwind.js"
echo " - /assets/js/axios.min.js"
echo " - /assets/js/lucide.js"

View File

@@ -0,0 +1,39 @@
#!/bin/bash
echo "=== Starting AITBC Miner Dashboard ==="
echo ""
# Find available port
PORT=8080
while [ $PORT -le 8090 ]; do
if ! netstat -tuln 2>/dev/null | grep -q ":$PORT "; then
echo "✓ Found available port: $PORT"
break
fi
echo "Port $port is in use, trying next..."
PORT=$((PORT + 1))
done
if [ $PORT -gt 8090 ]; then
echo "❌ No available ports found between 8080-8090"
exit 1
fi
# Start the dashboard
echo "Starting dashboard on port $PORT..."
nohup python3 -m http.server $PORT --bind 0.0.0.0 > dashboard.log 2>&1 &
PID=$!
echo ""
echo "✅ Dashboard is running!"
echo ""
echo "Access URLs:"
echo " Local: http://localhost:$PORT"
echo " Network: http://$(hostname -I | awk '{print $1}'):$PORT"
echo ""
echo "Dashboard file: miner-dashboard.html"
echo "Process ID: $PID"
echo "Log file: dashboard.log"
echo ""
echo "To stop: kill $PID"
echo "To view logs: tail -f dashboard.log"

View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Stop all AITBC services
echo "🛑 Stopping AITBC Services"
echo "========================"
# Stop by PID if file exists
if [ -f .service_pids ]; then
PIDS=$(cat .service_pids)
echo "Found PIDs: $PIDS"
for PID in $PIDS; do
if kill -0 $PID 2>/dev/null; then
echo "Stopping PID $PID..."
kill $PID
fi
done
rm -f .service_pids
fi
# Force kill any remaining services
echo "Cleaning up any remaining processes..."
sudo fuser -k 8000/tcp 2>/dev/null || true
sudo fuser -k 9080/tcp 2>/dev/null || true
sudo fuser -k 3001/tcp 2>/dev/null || true
sudo fuser -k 3002/tcp 2>/dev/null || true
pkill -f "uvicorn.*aitbc" 2>/dev/null || true
pkill -f "server.py" 2>/dev/null || true
echo "✅ All services stopped!"