chore: remove outdated documentation and reference files
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.11) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.12) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.13) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-summary (push) Has been cancelled

- Remove debugging service documentation (DEBUgging_SERVICES.md)
- Remove development logs policy and quick reference guides
- Remove E2E test creation summary
- Remove gift certificate example file
- Remove GitHub pull summary documentation
This commit is contained in:
2026-03-25 12:56:07 +01:00
parent 26f7dd5ad0
commit bfe6f94b75
229 changed files with 537 additions and 381 deletions

View File

@@ -0,0 +1,68 @@
#!/bin/bash
# Enhanced AITBC Service Management for Development
case "${1:-help}" in
"start")
echo "🚀 Starting AITBC services..."
sudo systemctl start aitbc-coordinator-api.service
sudo systemctl start aitbc-blockchain-node.service
sudo systemctl start aitbc-blockchain-rpc.service
echo "✅ Services started"
;;
"stop")
echo "🛑 Stopping AITBC services..."
sudo systemctl stop aitbc-coordinator-api.service
sudo systemctl stop aitbc-blockchain-node.service
sudo systemctl stop aitbc-blockchain-rpc.service
echo "✅ Services stopped"
;;
"restart")
echo "🔄 Restarting AITBC services..."
sudo systemctl restart aitbc-coordinator-api.service
sudo systemctl restart aitbc-blockchain-node.service
sudo systemctl restart aitbc-blockchain-rpc.service
echo "✅ Services restarted"
;;
"status")
echo "📊 AITBC Services Status:"
echo ""
sudo systemctl status aitbc-coordinator-api.service --no-pager -l
echo ""
sudo systemctl status aitbc-blockchain-node.service --no-pager -l
echo ""
sudo systemctl status aitbc-blockchain-rpc.service --no-pager -l
;;
"logs")
echo "📋 AITBC Service Logs (Ctrl+C to exit):"
sudo journalctl -u aitbc-coordinator-api.service -f
;;
"logs-all")
echo "📋 All AITBC Logs (Ctrl+C to exit):"
sudo journalctl -u aitbc-* -f
;;
"test")
echo "🧪 Testing AITBC services..."
echo "Testing Coordinator API..."
curl -s http://localhost:8000/health || echo "❌ Coordinator API not responding"
echo ""
echo "Testing Blockchain RPC..."
curl -s http://localhost:8006/health || echo "❌ Blockchain RPC not responding"
echo ""
echo "✅ Service test completed"
;;
"help"|*)
echo "🛠️ AITBC Development Service Management"
echo ""
echo "Usage: $0 {start|stop|restart|status|logs|logs-all|test|help}"
echo ""
echo "Commands:"
echo " start - Start all AITBC services"
echo " stop - Stop all AITBC services"
echo " restart - Restart all AITBC services"
echo " status - Show detailed service status"
echo " logs - Follow coordinator API logs"
echo " logs-all - Follow all AITBC service logs"
echo " test - Test service endpoints"
echo " help - Show this help message"
;;
esac

View File

@@ -0,0 +1,398 @@
#!/bin/bash
# AITBC Development Environment Startup Script
# Starts incus containers and all AITBC services on localhost
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to check if service is running
is_service_running() {
systemctl is-active --quiet "$1" 2>/dev/null
}
# Function to check if port is in use
is_port_in_use() {
netstat -tlnp 2>/dev/null | grep -q ":$1 "
}
# Function to check if service exists in container
service_exists_in_container() {
local container="$1"
local service="$2"
case $container in
"aitbc")
ssh aitbc-cascade "systemctl list-unit-files 2>/dev/null | grep -q '^${service}.service'" 2>/dev/null
;;
"aitbc1")
ssh aitbc1-cascade "systemctl list-unit-files 2>/dev/null | grep -q '^${service}.service'" 2>/dev/null
;;
*)
return 1
;;
esac
}
# Function to check if service is running in container
is_service_running_in_container() {
local container="$1"
local service="$2"
case $container in
"aitbc")
ssh aitbc-cascade "systemctl is-active --quiet '$service' 2>/dev/null" 2>/dev/null
;;
"aitbc1")
ssh aitbc1-cascade "systemctl is-active --quiet '$service' 2>/dev/null" 2>/dev/null
;;
*)
return 1
;;
esac
}
# Function to get container IP
get_container_ip() {
local container="$1"
case $container in
"aitbc")
ssh aitbc-cascade "hostname -I | awk '{print \$1}'" 2>/dev/null || echo "N/A"
;;
"aitbc1")
ssh aitbc1-cascade "hostname -I | awk '{print \$1}'" 2>/dev/null || echo "N/A"
;;
*)
echo "N/A"
;;
esac
}
print_status "Starting AITBC Development Environment..."
# Check prerequisites
if ! command_exists incus; then
print_error "incus command not found. Please install incus first."
exit 1
fi
if ! command_exists systemctl; then
print_error "systemctl command not found. This script requires systemd."
exit 1
fi
# Step 1: Check remote containers via SSH
print_status "Checking remote containers via SSH..."
containers=("aitbc" "aitbc1")
for container in "${containers[@]}"; do
print_status "Checking container: $container"
case $container in
"aitbc")
if ssh aitbc-cascade "echo 'Container is accessible'" >/dev/null 2>&1; then
print_success "Container $container is accessible via SSH"
else
print_error "Container $container is not accessible via SSH"
exit 1
fi
;;
"aitbc1")
if ssh aitbc1-cascade "echo 'Container is accessible'" >/dev/null 2>&1; then
print_success "Container $container is accessible via SSH"
else
print_error "Container $container is not accessible via SSH"
exit 1
fi
;;
esac
done
# Step 2: Wait for containers to be fully ready
print_status "Waiting for containers to be ready..."
sleep 5
# Step 3: Get container IPs for location detection
declare -A container_ips
for container in "${containers[@]}"; do
container_ip=$(get_container_ip "$container")
container_ips["$container"]="$container_ip"
done
# Step 3: Start AITBC systemd services on localhost
print_status "Starting AITBC systemd services on localhost..."
# Get all AITBC services (fixed to handle column alignment issues)
aitbc_services=$(systemctl list-units --all | grep "aitbc-" | awk '{print $2}' | grep "\.service$" | grep -v "not-found")
# Filter out invalid service names
filtered_services=""
for service in $aitbc_services; do
# Skip invalid or malformed service names
if [[ "$service" =~ [^a-zA-Z0-9\-\._] ]]; then
print_warning "Skipping invalid service name: $service"
continue
fi
filtered_services="$filtered_services $service"
done
aitbc_services="$filtered_services"
if [ -z "$aitbc_services" ]; then
print_warning "No AITBC services found on localhost"
else
print_status "Found AITBC services:"
echo "$aitbc_services" | sed 's/^/ - /'
# Start each service
for service in $aitbc_services; do
service_name=$(echo "$service" | sed 's/\.service$//')
print_status "Starting service: $service_name"
if is_service_running "$service_name"; then
print_warning "Service $service_name is already running"
else
if systemctl start "$service_name"; then
print_success "Service $service_name started successfully"
else
print_error "Failed to start service $service_name"
fi
fi
done
fi
# Step 4: Wait for services to initialize
print_status "Waiting for services to initialize..."
sleep 10
# Step 6: Check service status with location information
print_status "Checking service status with location information..."
# Check systemd services on localhost
if [ -n "$aitbc_services" ]; then
print_status "Local Systemd Services Status:"
for service in $aitbc_services; do
service_name=$(echo "$service" | sed 's/\.service$//')
if is_service_running "$service_name"; then
print_success "$service_name: RUNNING (LOCAL)"
else
print_error "$service_name: NOT RUNNING (LOCAL)"
fi
done
fi
# Check services in containers
print_status "Container Services Status:"
# Define services to check in containers
container_services=("aitbc-coordinator-api" "aitbc-wallet-daemon" "aitbc-blockchain-node-1" "aitbc-blockchain-node-2" "aitbc-exchange-api" "aitbc-explorer")
for container in "${containers[@]}"; do
container_ip="${container_ips[$container]}"
print_status "Container $container (IP: $container_ip):"
for service in "${container_services[@]}"; do
if service_exists_in_container "$container" "$service"; then
if is_service_running_in_container "$container" "$service"; then
print_success " $service: RUNNING (in $container)"
else
print_error " $service: NOT RUNNING (in $container)"
fi
else
print_warning " $service: NOT FOUND (in $container)"
fi
done
done
# Check common AITBC ports with location detection
print_status "Checking AITBC service ports with location detection..."
ports=(
"8000:Coordinator API"
"8001:Exchange API"
"8002:Blockchain Node"
"8003:Blockchain RPC"
"8080:Container Coordinator API"
"8081:Container Blockchain Node 1"
"8082:Container Exchange API"
"8083:Container Wallet Daemon"
"8084:Container Blockchain Node 2"
"8085:Container Explorer UI"
"8086:Container Marketplace"
"8087:Container Miner Dashboard"
"8088:Container Load Balancer"
"8089:Container Debug API"
)
for port_info in "${ports[@]}"; do
port=$(echo "$port_info" | cut -d: -f1)
service_name=$(echo "$port_info" | cut -d: -f2)
if is_port_in_use "$port"; then
# Try to determine which process is using the port
process_info=$(netstat -tlnp 2>/dev/null | grep ":$port " | head -1)
if [ -n "$process_info" ]; then
pid=$(echo "$process_info" | awk '{print $7}' | cut -d/ -f1)
if [ -n "$pid" ] && [ "$pid" != "-" ]; then
# Check if it's a local process
if ps -p "$pid" -o command= 2>/dev/null | grep -q "python.*uvicorn"; then
print_success "$service_name (port $port): RUNNING (LOCAL - PID $pid)"
else
print_success "$service_name (port $port): RUNNING (PID $pid)"
fi
else
print_success "$service_name (port $port): RUNNING"
fi
else
print_success "$service_name (port $port): RUNNING"
fi
else
# Check if service might be running in a container
found_in_container=false
for container in "${containers[@]}"; do
container_ip="${container_ips[$container]}"
if [ "$container_ip" != "N/A" ]; then
if timeout 3 bash -c "</dev/tcp/$container_ip/$port" 2>/dev/null; then
print_warning "$service_name (port $port): RUNNING (in container $container)"
found_in_container=true
break
fi
fi
done
if [ "$found_in_container" = false ]; then
print_warning "$service_name (port $port): NOT RUNNING"
fi
fi
done
# Step 7: Test health endpoints with location detection
print_status "Testing health endpoints with location detection..."
health_endpoints=(
"http://localhost:8000/health:Coordinator API"
"http://localhost:8001/health:Exchange API"
"http://localhost:8003/health:Blockchain RPC"
"http://localhost:8004/health:Blockchain Node 2"
"http://localhost:8005/health:Blockchain RPC 2"
"http://localhost:8080/health:Container Coordinator API"
"http://localhost:8083/health:Container Wallet Daemon"
)
for endpoint_info in "${health_endpoints[@]}"; do
url=$(echo "$endpoint_info" | cut -d: -f1-3)
service_name=$(echo "$endpoint_info" | cut -d: -f4)
if curl -s --max-time 5 "$url" >/dev/null 2>&1; then
print_success "$service_name: HEALTHY (LOCAL)"
else
# Check if service is available in containers
found_in_container=false
for container in "${containers[@]}"; do
container_ip="${container_ips[$container]}"
if [ "$container_ip" != "N/A" ]; then
container_url="http://$container_ip:$(echo "$url" | cut -d: -f3)/health"
if curl -s --max-time 3 "$container_url" >/dev/null 2>&1; then
print_success "$service_name: HEALTHY (in $container)"
found_in_container=true
break
fi
fi
done
if [ "$found_in_container" = false ]; then
print_warning "$service_name: NOT RESPONDING"
fi
fi
done
# Step 7: Check remote container status
print_status "Checking remote container status..."
for container in "${containers[@]}"; do
container_ip="${container_ips[$container]}"
case $container in
"aitbc")
if ssh aitbc-cascade "echo 'Container is running'" >/dev/null 2>&1; then
print_success "Container $container: RUNNING (SSH accessible)"
print_status " IP: $container_ip"
print_status " Access: ssh aitbc-cascade"
else
print_error "Container $container: NOT ACCESSIBLE"
fi
;;
"aitbc1")
if ssh aitbc1-cascade "echo 'Container is running'" >/dev/null 2>&1; then
print_success "Container $container: RUNNING (SSH accessible)"
print_status " IP: $container_ip"
print_status " Access: ssh aitbc1-cascade"
else
print_error "Container $container: NOT ACCESSIBLE"
fi
;;
esac
done
print_success "AITBC Development Environment startup complete!"
print_status "Summary:"
echo " - Incus containers: ${#containers[@]} started"
echo " - Systemd services: $(echo "$aitbc_services" | wc -l) found"
echo " - Check individual service logs with: journalctl -u <service-name>"
echo " - Access services at their respective ports"
echo ""
print_status "Useful commands:"
echo " - Check all AITBC services: systemctl list-units | grep aitbc-"
echo " - Access aitbc container: ssh aitbc-cascade"
echo " - Access aitbc1 container: ssh aitbc1-cascade"
echo " - View local service logs: journalctl -f -u <service-name>"
echo " - View container service logs: ssh aitbc-cascade 'journalctl -f -u <service-name>'"
echo " - Check container services: ssh aitbc-cascade 'systemctl status <service-name>'"
echo " - Check all services in aitbc: ssh aitbc-cascade 'systemctl list-units | grep aitbc-'"
echo " - Check all services in aitbc1: ssh aitbc1-cascade 'systemctl list-units | grep aitbc-'"
echo " - Stop all services: ./scripts/stop-aitbc-dev.sh"
echo ""
print_status "Debug specific issues:"
echo " - Debug aitbc coordinator: ssh aitbc-cascade 'systemctl status aitbc-coordinator-api'"
echo " - Debug aitbc1 coordinator: ssh aitbc1-cascade 'systemctl status aitbc-coordinator-api'"
echo " - Debug aitbc wallet: ssh aitbc-cascade 'systemctl status aitbc-wallet-daemon'"
echo " - Debug aitbc blockchain 1: ssh aitbc-cascade 'systemctl status aitbc-blockchain-node-1'"
echo " - Debug local blockchain 2: systemctl status aitbc-blockchain-node-2"
echo " - Debug aitbc exchange: ssh aitbc-cascade 'systemctl status aitbc-exchange-api'"
echo ""
print_status "Port Migration Commands:"
echo " - Update container coordinator to port 8080: ssh aitbc-cascade 'sudo systemctl edit aitbc-coordinator-api.service'"
echo " - Update container exchange to port 8082: ssh aitbc-cascade 'sudo systemctl edit aitbc-exchange-api.service'"
echo " - Update wallet daemon to port 8083: ssh aitbc-cascade 'sudo systemctl edit aitbc-wallet-daemon.service'"
echo " - Blockchain Node 2: Runs in container on port 8084 (not localhost)"
echo " - Blockchain Node 1: Use port 8081 (container)"
echo ""
print_status "Service URLs:"
echo " - Coordinator API: http://localhost:8000"
echo " - Exchange API: http://localhost:8001"
echo " - Blockchain RPC: http://localhost:8003"
echo " - Container Services: http://localhost:8080-8089"
echo " - Blockchain Node 2: http://localhost:8084 (container only)"

View File

@@ -0,0 +1,291 @@
#!/bin/bash
# AITBC Full Development Environment Startup Script
# Starts incus containers, services inside containers, and all AITBC services on localhost
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to check if service is running
is_service_running() {
systemctl is-active --quiet "$1" 2>/dev/null
}
# Function to check if port is in use
is_port_in_use() {
netstat -tlnp 2>/dev/null | grep -q ":$1 "
}
print_status "Starting AITBC Full Development Environment..."
# Check prerequisites
if ! command_exists incus; then
print_error "incus command not found. Please install incus first."
exit 1
fi
if ! command_exists systemctl; then
print_error "systemctl command not found. This script requires systemd."
exit 1
fi
# Step 1: Start incus containers
print_status "Starting incus containers..."
containers=("aitbc" "aitbc1")
for container in "${containers[@]}"; do
print_status "Starting container: $container"
if incus info "$container" >/dev/null 2>&1; then
if incus info "$container" | grep -q "Status: RUNNING"; then
print_warning "Container $container is already running"
else
if incus start "$container"; then
print_success "Container $container started successfully"
else
print_error "Failed to start container $container"
exit 1
fi
fi
else
print_error "Container $container not found. Please create it first."
exit 1
fi
done
# Step 2: Wait for containers to be fully ready
print_status "Waiting for containers to be ready..."
sleep 10
# Step 3: Start services inside containers
print_status "Starting AITBC services inside containers..."
container_services=(
"aitbc:aitbc-coordinator-api"
"aitbc:aitbc-wallet-daemon"
"aitbc:aitbc-blockchain-node"
"aitbc1:aitbc-coordinator-api"
"aitbc1:aitbc-wallet-daemon"
"aitbc1:aitbc-blockchain-node"
)
for service_info in "${container_services[@]}"; do
container=$(echo "$service_info" | cut -d: -f1)
service=$(echo "$service_info" | cut -d: -f2)
print_status "Starting $service in container $container"
# Check if service exists in container
if incus exec "$container" -- systemctl list-unit-files | grep -q "$service.service"; then
# Start the service inside container
if incus exec "$container" -- systemctl start "$service"; then
print_success "$service started in $container"
else
print_warning "Failed to start $service in $container (may not be installed)"
fi
else
print_warning "$service not found in $container"
fi
done
# Step 4: Start AITBC systemd services on localhost
print_status "Starting AITBC systemd services on localhost..."
# Get all AITBC services (filter out invalid characters)
aitbc_services=$(systemctl list-units --all | grep "aitbc-" | grep -v "●" | awk '{print $1}' | grep -v "not-found" | grep -v "loaded")
if [ -z "$aitbc_services" ]; then
print_warning "No AITBC services found on localhost"
else
print_status "Found AITBC services:"
echo "$aitbc_services" | sed 's/^/ - /'
# Start each service
for service in $aitbc_services; do
service_name=$(echo "$service" | sed 's/\.service$//')
print_status "Starting service: $service_name"
if is_service_running "$service_name"; then
print_warning "Service $service_name is already running"
else
if systemctl start "$service_name"; then
print_success "Service $service_name started successfully"
else
print_error "Failed to start service $service_name"
fi
fi
done
fi
# Step 5: Wait for services to initialize
print_status "Waiting for services to initialize..."
sleep 15
# Step 6: Check service status
print_status "Checking service status..."
# Check systemd services on localhost
if [ -n "$aitbc_services" ]; then
print_status "Local Systemd Services Status:"
for service in $aitbc_services; do
service_name=$(echo "$service" | sed 's/\.service$//')
if is_service_running "$service_name"; then
print_success "$service_name: RUNNING"
else
print_error "$service_name: NOT RUNNING"
fi
done
fi
# Check services in containers
print_status "Container Services Status:"
for service_info in "${container_services[@]}"; do
container=$(echo "$service_info" | cut -d: -f1)
service=$(echo "$service_info" | cut -d: -f2)
if incus exec "$container" -- systemctl is-active --quiet "$service" 2>/dev/null; then
print_success "$service in $container: RUNNING"
else
print_warning "$service in $container: NOT RUNNING"
fi
done
# Check common AITBC ports
print_status "Checking AITBC service ports..."
ports=(
"8001:Coordinator API"
"8002:Wallet Daemon"
"8003:Blockchain RPC"
"8000:Coordinator API (alt)"
"8081:Blockchain Node 1"
"8082:Blockchain Node 2"
"8006:Coordinator API (dev)"
)
for port_info in "${ports[@]}"; do
port=$(echo "$port_info" | cut -d: -f1)
service_name=$(echo "$port_info" | cut -d: -f2)
if is_port_in_use "$port"; then
print_success "$service_name (port $port): RUNNING"
else
print_warning "$service_name (port $port): NOT RUNNING"
fi
done
# Step 7: Test health endpoints
print_status "Testing health endpoints..."
health_endpoints=(
"http://localhost:8001/health:Coordinator API"
"http://localhost:8002/health:Wallet Daemon"
"http://localhost:8003/health:Blockchain RPC"
)
for endpoint_info in "${health_endpoints[@]}"; do
url=$(echo "$endpoint_info" | cut -d: -f1-3)
service_name=$(echo "$endpoint_info" | cut -d: -f4)
if curl -s --max-time 5 "$url" >/dev/null 2>&1; then
print_success "$service_name: HEALTHY"
else
print_warning "$service_name: NOT RESPONDING"
fi
done
# Step 8: Container status and IPs
print_status "Container status and network information..."
for container in "${containers[@]}"; do
if incus info "$container" | grep -q "Status: RUNNING"; then
print_success "Container $container: RUNNING"
# Get container IP
container_ip=$(incus exec "$container" -- ip addr show eth0 2>/dev/null | grep "inet " | awk '{print $2}' | cut -d/ -f1 || echo "N/A")
if [ "$container_ip" != "N/A" ]; then
print_status " IP: $container_ip"
# Test connectivity to container services
print_status " Testing container services:"
for service_info in "${container_services[@]}"; do
cont=$(echo "$service_info" | cut -d: -f1)
serv=$(echo "$service_info" | cut -d: -f2)
if [ "$cont" = "$container" ]; then
case $serv in
"aitbc-coordinator-api")
if curl -s --max-time 3 "http://$container_ip:8001/health" >/dev/null 2>&1; then
print_success " Coordinator API: HEALTHY"
else
print_warning " Coordinator API: NOT RESPONDING"
fi
;;
"aitbc-wallet-daemon")
if curl -s --max-time 3 "http://$container_ip:8002/health" >/dev/null 2>&1; then
print_success " Wallet Daemon: HEALTHY"
else
print_warning " Wallet Daemon: NOT RESPONDING"
fi
;;
"aitbc-blockchain-node")
if curl -s --max-time 3 "http://$container_ip:8003/health" >/dev/null 2>&1; then
print_success " Blockchain Node: HEALTHY"
else
print_warning " Blockchain Node: NOT RESPONDING"
fi
;;
esac
fi
done
fi
else
print_error "Container $container: NOT RUNNING"
fi
done
print_success "AITBC Full Development Environment startup complete!"
print_status "Summary:"
echo " - Incus containers: ${#containers[@]} started"
echo " - Local systemd services: $(echo "$aitbc_services" | wc -l) found"
echo " - Container services: ${#container_services[@]} attempted"
echo ""
print_status "Useful commands:"
echo " - Check all AITBC services: systemctl list-units | grep aitbc-"
echo " - Check container status: incus list"
echo " - View service logs: journalctl -f -u aitbc-coordinator-api"
echo " - View container logs: incus exec aitbc -- journalctl -f -u aitbc-coordinator-api"
echo " - Stop all services: ./scripts/stop-aitbc-full.sh"
echo ""
print_status "Service URLs:"
echo " - Coordinator API: http://localhost:8001"
echo " - Wallet Daemon: http://localhost:8002"
echo " - Blockchain RPC: http://localhost:8003"

View File

@@ -0,0 +1,6 @@
#!/bin/bash
cd /opt/aitbc/apps/coordinator-api
export PATH=/opt/aitbc/apps/coordinator-api/.venv/bin
export PYTHONPATH=/opt/aitbc/apps/coordinator-api/src
export MINER_API_KEYS='["miner_test_abc123"]'
exec /opt/aitbc/apps/coordinator-api/.venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --log-level info

View File

@@ -0,0 +1,309 @@
#!/bin/bash
# AITBC Development Environment Enhanced Stop Script
# Stops incus containers and all AITBC services on localhost
# Enhanced to handle persistent services with auto-restart configuration
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_persistent() {
echo -e "${PURPLE}[PERSISTENT]${NC} $1"
}
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to check if service is running
is_service_running() {
systemctl is-active --quiet "$1" 2>/dev/null
}
# Function to check if service has auto-restart configured
has_auto_restart() {
systemctl show "$1" -p Restart | grep -q "Restart=yes\|Restart=always"
}
# Function to force stop a persistent service
force_stop_service() {
local service_name="$1"
local max_attempts=3
local attempt=1
print_persistent "Service $service_name has auto-restart - applying enhanced stop procedure..."
# Disable auto-restart temporarily
if systemctl show "$service_name" -p Restart | grep -q "Restart=always"; then
print_status "Temporarily disabling auto-restart for $service_name"
sudo systemctl kill -s SIGSTOP "$service_name" 2>/dev/null || true
fi
# Try to stop with increasing force
while [ $attempt -le $max_attempts ]; do
print_status "Attempt $attempt/$max_attempts to stop $service_name"
case $attempt in
1)
# First attempt: normal stop
systemctl stop "$service_name" 2>/dev/null || true
;;
2)
# Second attempt: kill main process
main_pid=$(systemctl show "$service_name" -p MainPID | cut -d'=' -f2)
if [ "$main_pid" != "0" ]; then
print_status "Killing main PID $main_pid for $service_name"
sudo kill -TERM "$main_pid" 2>/dev/null || true
fi
;;
3)
# Third attempt: force kill
print_status "Force killing all processes for $service_name"
sudo pkill -f "$service_name" 2>/dev/null || true
sudo systemctl kill -s SIGKILL "$service_name" 2>/dev/null || true
;;
esac
# Wait and check
sleep 2
if ! is_service_running "$service_name"; then
print_success "Service $service_name stopped on attempt $attempt"
return 0
fi
attempt=$((attempt + 1))
done
# If still running, try service masking
print_persistent "Service $service_name still persistent - trying service masking..."
service_file="/etc/systemd/system/$service_name.service"
if [ -f "$service_file" ]; then
sudo mv "$service_file" "${service_file}.bak" 2>/dev/null || true
sudo systemctl daemon-reload 2>/dev/null || true
systemctl stop "$service_name" 2>/dev/null || true
sleep 2
if ! is_service_running "$service_name"; then
print_success "Service $service_name stopped via service masking"
# Restore the service file
sudo mv "${service_file}.bak" "$service_file" 2>/dev/null || true
sudo systemctl daemon-reload 2>/dev/null || true
return 0
else
# Restore the service file even if still running
sudo mv "${service_file}.bak" "$service_file" 2>/dev/null || true
sudo systemctl daemon-reload 2>/dev/null || true
fi
fi
print_error "Failed to stop persistent service $service_name after $max_attempts attempts"
return 1
}
print_status "Stopping AITBC Development Environment (Enhanced)..."
# Check prerequisites
if ! command_exists incus; then
print_error "incus command not found. Please install incus first."
exit 1
fi
if ! command_exists systemctl; then
print_error "systemctl command not found. This script requires systemd."
exit 1
fi
# Step 1: Stop AITBC systemd services on localhost
print_status "Stopping AITBC systemd services on localhost..."
# Get all AITBC services
aitbc_services=$(systemctl list-units --all | grep "aitbc-" | awk '{print $1}' | grep -v "not-found")
if [ -z "$aitbc_services" ]; then
print_warning "No AITBC services found on localhost"
else
print_status "Found AITBC services:"
echo "$aitbc_services" | sed 's/^/ - /'
# Categorize services
normal_services=""
persistent_services=""
for service in $aitbc_services; do
service_name=$(echo "$service" | sed 's/\.service$//')
if has_auto_restart "$service_name"; then
persistent_services="$persistent_services $service_name"
else
normal_services="$normal_services $service_name"
fi
done
# Stop normal services first
if [ -n "$normal_services" ]; then
print_status "Stopping normal services..."
for service_name in $normal_services; do
print_status "Stopping service: $service_name"
if is_service_running "$service_name"; then
if systemctl stop "$service_name"; then
print_success "Service $service_name stopped successfully"
else
print_error "Failed to stop service $service_name"
fi
else
print_warning "Service $service_name is already stopped"
fi
done
fi
# Stop persistent services with enhanced procedure
if [ -n "$persistent_services" ]; then
print_status "Stopping persistent services with enhanced procedure..."
for service_name in $persistent_services; do
print_status "Processing persistent service: $service_name"
if is_service_running "$service_name"; then
if force_stop_service "$service_name"; then
print_success "Persistent service $service_name stopped successfully"
else
print_error "Failed to stop persistent service $service_name"
fi
else
print_warning "Persistent service $service_name is already stopped"
fi
done
fi
fi
# Step 2: Stop incus containers
print_status "Stopping incus containers..."
containers=("aitbc" "aitbc1")
for container in "${containers[@]}"; do
print_status "Stopping container: $container"
if incus info "$container" >/dev/null 2>&1; then
# Check if container is running
if incus info "$container" | grep -q "Status: RUNNING"; then
if incus stop "$container"; then
print_success "Container $container stopped successfully"
else
print_error "Failed to stop container $container"
fi
else
print_warning "Container $container is already stopped"
fi
else
print_warning "Container $container not found"
fi
done
# Step 3: Verify services are stopped
print_status "Verifying services are stopped..."
# Check systemd services
if [ -n "$aitbc_services" ]; then
print_status "Systemd Services Status:"
stopped_count=0
running_count=0
for service in $aitbc_services; do
service_name=$(echo "$service" | sed 's/\.service$//')
if is_service_running "$service_name"; then
print_error "$service_name: STILL RUNNING"
running_count=$((running_count + 1))
else
print_success "$service_name: STOPPED"
stopped_count=$((stopped_count + 1))
fi
done
# Calculate success rate
total_services=$((stopped_count + running_count))
success_rate=$(( (stopped_count * 100) / total_services ))
if [ $running_count -eq 0 ]; then
print_success "All systemd services stopped successfully (100%)"
elif [ $success_rate -ge 90 ]; then
print_success "Most systemd services stopped successfully (${success_rate}%)"
else
print_warning "Some systemd services still running (${success_rate}% success)"
fi
fi
# Check containers
print_status "Container Status:"
stopped_containers=0
running_containers=0
for container in "${containers[@]}"; do
if incus info "$container" >/dev/null 2>&1; then
if incus info "$container" | grep -q "Status: RUNNING"; then
print_error "Container $container: STILL RUNNING"
running_containers=$((running_containers + 1))
else
print_success "Container $container: STOPPED"
stopped_containers=$((stopped_containers + 1))
fi
else
print_warning "Container $container: NOT FOUND"
fi
done
# Final summary
total_containers=$((stopped_containers + running_containers))
if [ -n "$aitbc_services" ]; then
total_services=$(echo "$aitbc_services" | wc -l)
else
total_services=0
fi
print_success "AITBC Development Environment shutdown complete!"
print_status "Summary:"
echo " - Incus containers: ${stopped_containers}/${total_containers} stopped"
echo " - Systemd services: ${stopped_count}/${total_services} stopped"
if [ $running_containers -gt 0 ] || [ $running_count -gt 0 ]; then
echo ""
print_warning "Some components are still running:"
if [ $running_containers -gt 0 ]; then
echo " - $running_containers container(s) still running"
fi
if [ $running_count -gt 0 ]; then
echo " - $running_count service(s) still running (likely persistent services)"
fi
echo ""
print_status "You may need to manually stop persistent services or use:"
echo " sudo systemctl kill --signal=SIGKILL <service-name>"
else
echo ""
print_success "All components stopped successfully (100%)"
fi
echo ""
print_status "To start again: ./scripts/start-aitbc-dev.sh"

View File

@@ -0,0 +1,281 @@
#!/bin/bash
# AITBC Development Environment Stop Script
# Stops incus containers and all AITBC services on localhost
# Enhanced to handle persistent services with auto-restart configuration
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_persistent() {
echo -e "${PURPLE}[PERSISTENT]${NC} $1"
}
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to check if service is running
is_service_running() {
systemctl is-active --quiet "$1" 2>/dev/null
}
# Function to check if service has auto-restart configured
has_auto_restart() {
systemctl show "$1" -p Restart | grep -q "Restart=yes\|Restart=always"
}
# Function to force stop a persistent service
force_stop_service() {
local service_name="$1"
local max_attempts=3
local attempt=1
print_persistent "Service $service_name has auto-restart - applying enhanced stop procedure..."
# Try to stop with increasing force
while [ $attempt -le $max_attempts ]; do
print_status "Attempt $attempt/$max_attempts to stop $service_name"
case $attempt in
1)
# First attempt: normal stop
systemctl stop "$service_name" 2>/dev/null || true
;;
2)
# Second attempt: kill main process
main_pid=$(systemctl show "$service_name" -p MainPID | cut -d'=' -f2)
if [ "$main_pid" != "0" ]; then
print_status "Killing main PID $main_pid for $service_name"
sudo kill -TERM "$main_pid" 2>/dev/null || true
fi
;;
3)
# Third attempt: force kill all processes
print_status "Force killing all processes for $service_name"
sudo pkill -f "$service_name" 2>/dev/null || true
sudo systemctl kill -s SIGKILL "$service_name" 2>/dev/null || true
;;
esac
# Wait and check
sleep 2
if ! is_service_running "$service_name"; then
print_success "Service $service_name stopped on attempt $attempt"
return 0
fi
attempt=$((attempt + 1))
done
print_error "Failed to stop persistent service $service_name after $max_attempts attempts"
return 1
}
print_status "Stopping AITBC Development Environment..."
# Check prerequisites
if ! command_exists incus; then
print_error "incus command not found. Please install incus first."
exit 1
fi
if ! command_exists systemctl; then
print_error "systemctl command not found. This script requires systemd."
exit 1
fi
# Step 1: Stop AITBC systemd services on localhost
print_status "Stopping AITBC systemd services on localhost..."
# Get all AITBC services
aitbc_services=$(systemctl list-units --all | grep "aitbc-" | awk '{print $1}' | grep -v "not-found")
if [ -z "$aitbc_services" ]; then
print_warning "No AITBC services found on localhost"
else
print_status "Found AITBC services:"
echo "$aitbc_services" | sed 's/^/ - /'
# Categorize services
normal_services=""
persistent_services=""
for service in $aitbc_services; do
service_name=$(echo "$service" | sed 's/\.service$//')
if has_auto_restart "$service_name"; then
persistent_services="$persistent_services $service_name"
else
normal_services="$normal_services $service_name"
fi
done
# Stop normal services first
if [ -n "$normal_services" ]; then
print_status "Stopping normal services..."
for service_name in $normal_services; do
print_status "Stopping service: $service_name"
if is_service_running "$service_name"; then
if systemctl stop "$service_name"; then
print_success "Service $service_name stopped successfully"
else
print_error "Failed to stop service $service_name"
fi
else
print_warning "Service $service_name is already stopped"
fi
done
fi
# Stop persistent services with enhanced procedure
if [ -n "$persistent_services" ]; then
print_status "Stopping persistent services with enhanced procedure..."
for service_name in $persistent_services; do
print_status "Processing persistent service: $service_name"
if is_service_running "$service_name"; then
if force_stop_service "$service_name"; then
print_success "Persistent service $service_name stopped successfully"
else
print_error "Failed to stop persistent service $service_name"
fi
else
print_warning "Persistent service $service_name is already stopped"
fi
done
fi
fi
# Step 2: Stop incus containers
print_status "Stopping incus containers..."
containers=("aitbc" "aitbc1")
for container in "${containers[@]}"; do
print_status "Stopping container: $container"
if incus info "$container" >/dev/null 2>&1; then
# Check if container is running
if incus info "$container" | grep -q "Status: RUNNING"; then
if incus stop "$container"; then
print_success "Container $container stopped successfully"
else
print_error "Failed to stop container $container"
fi
else
print_warning "Container $container is already stopped"
fi
else
print_warning "Container $container not found"
fi
done
# Step 3: Verify services are stopped
print_status "Verifying services are stopped..."
# Check systemd services
if [ -n "$aitbc_services" ]; then
print_status "Systemd Services Status:"
stopped_count=0
running_count=0
for service in $aitbc_services; do
service_name=$(echo "$service" | sed 's/\.service$//')
if is_service_running "$service_name"; then
print_error "$service_name: STILL RUNNING"
running_count=$((running_count + 1))
else
print_success "$service_name: STOPPED"
stopped_count=$((stopped_count + 1))
fi
done
# Calculate success rate
total_services=$((stopped_count + running_count))
success_rate=$(( (stopped_count * 100) / total_services ))
if [ $running_count -eq 0 ]; then
print_success "All systemd services stopped successfully (100%)"
elif [ $success_rate -ge 90 ]; then
print_success "Most systemd services stopped successfully (${success_rate}%)"
else
print_warning "Some systemd services still running (${success_rate}% success)"
fi
fi
# Check containers
print_status "Container Status:"
stopped_containers=0
running_containers=0
for container in "${containers[@]}"; do
if incus info "$container" >/dev/null 2>&1; then
if incus info "$container" | grep -q "Status: RUNNING"; then
print_error "Container $container: STILL RUNNING"
running_containers=$((running_containers + 1))
else
print_success "Container $container: STOPPED"
stopped_containers=$((stopped_containers + 1))
fi
else
print_warning "Container $container: NOT FOUND"
fi
done
# Final summary
total_containers=$((stopped_containers + running_containers))
if [ -n "$aitbc_services" ]; then
total_services=$(echo "$aitbc_services" | wc -l)
else
total_services=0
fi
print_success "AITBC Development Environment shutdown complete!"
print_status "Summary:"
echo " - Incus containers: ${stopped_containers}/${total_containers} stopped"
echo " - Systemd services: ${stopped_count}/${total_services} stopped"
if [ $running_containers -gt 0 ] || [ $running_count -gt 0 ]; then
echo ""
print_warning "Some components are still running:"
if [ $running_containers -gt 0 ]; then
echo " - $running_containers container(s) still running"
fi
if [ $running_count -gt 0 ]; then
echo " - $running_count service(s) still running (likely persistent services)"
fi
echo ""
print_status "You may need to manually stop persistent services or use:"
echo " sudo systemctl kill --signal=SIGKILL <service-name>"
else
echo ""
print_success "All components stopped successfully (100%)"
fi
echo ""
print_status "To start again: ./scripts/start-aitbc-dev.sh"