chore(cleanup): remove obsolete scripts and update paths for production deployment

- Remove dev/scripts/check-file-organization.sh (obsolete organization checker)
- Remove dev/scripts/community_onboarding.py (unused 559-line automation script)
- Update gpu_miner_host.py log path from /home/oib/windsurf/aitbc to /opt/aitbc
- Add service status and standardization badges to README.md
This commit is contained in:
oib
2026-03-04 13:24:38 +01:00
parent 50954a4b31
commit 3df0a9ed62
126 changed files with 1870 additions and 458 deletions

View File

@@ -0,0 +1,86 @@
#!/bin/bash
# scripts/check-file-organization.sh
echo "🔍 Checking project file organization..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Count issues
ISSUES=0
# Function to report issue
report_issue() {
local file="$1"
local issue="$2"
local suggestion="$3"
echo -e "${RED}❌ ISSUE: $file${NC}"
echo -e " ${YELLOW}Problem: $issue${NC}"
echo -e " ${BLUE}Suggestion: $suggestion${NC}"
echo ""
((ISSUES++))
}
# Check root directory for misplaced files
echo "📁 Checking root directory..."
cd "$(dirname "$0")/.."
# Test files
for file in test_*.py test_*.sh run_mc_test.sh; do
if [[ -f "$file" ]]; then
report_issue "$file" "Test file at root level" "Move to dev/tests/"
fi
done
# Development scripts
for file in patch_*.py fix_*.py simple_test.py; do
if [[ -f "$file" ]]; then
report_issue "$file" "Development script at root level" "Move to dev/scripts/"
fi
done
# Multi-chain files
for file in MULTI_*.md; do
if [[ -f "$file" ]]; then
report_issue "$file" "Multi-chain file at root level" "Move to dev/multi-chain/"
fi
done
# Environment files
for dir in node_modules .venv cli_env logs .pytest_cache .ruff_cache .vscode; do
if [[ -d "$dir" ]]; then
report_issue "$dir" "Environment directory at root level" "Move to dev/env/ or dev/cache/"
fi
done
# Configuration files
for file in .aitbc.yaml .aitbc.yaml.example .env.production .nvmrc .lycheeignore; do
if [[ -f "$file" ]]; then
report_issue "$file" "Configuration file at root level" "Move to config/"
fi
done
# Check if essential files are missing
echo "📋 Checking essential files..."
ESSENTIAL_FILES=(".editorconfig" ".env.example" ".gitignore" "LICENSE" "README.md" "pyproject.toml" "poetry.lock" "pytest.ini" "run_all_tests.sh")
for file in "${ESSENTIAL_FILES[@]}"; do
if [[ ! -f "$file" ]]; then
echo -e "${YELLOW}⚠️ WARNING: Essential file '$file' is missing${NC}"
fi
done
# Summary
if [[ $ISSUES -eq 0 ]]; then
echo -e "${GREEN}✅ File organization is perfect! No issues found.${NC}"
exit 0
else
echo -e "${RED}❌ Found $ISSUES organization issue(s)${NC}"
echo -e "${BLUE}💡 Run './scripts/move-to-right-folder.sh --auto' to fix automatically${NC}"
exit 1
fi

View File

@@ -0,0 +1,177 @@
#!/bin/bash
# AITBC Development Services Manager
# Starts AITBC services for development and provides cleanup option
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
LOG_DIR="$PROJECT_ROOT/logs"
PID_FILE="$PROJECT_ROOT/.aitbc_dev_pids"
# Create logs directory if it doesn't exist
mkdir -p "$LOG_DIR"
# Color codes for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Services to manage
SERVICES=(
"aitbc-blockchain-node.service"
"aitbc-blockchain-rpc.service"
"aitbc-gpu-miner.service"
"aitbc-mock-coordinator.service"
)
start_services() {
echo -e "${BLUE}Starting AITBC development services...${NC}"
# Check if services are already running
for service in "${SERVICES[@]}"; do
if systemctl is-active --quiet "$service"; then
echo -e "${YELLOW}Warning: $service is already running${NC}"
fi
done
# Start all services
for service in "${SERVICES[@]}"; do
echo -e "Starting $service..."
sudo systemctl start "$service"
# Wait a moment and check if it started successfully
sleep 2
if systemctl is-active --quiet "$service"; then
echo -e "${GREEN}$service started successfully${NC}"
echo "$service" >> "$PID_FILE"
else
echo -e "${RED}✗ Failed to start $service${NC}"
echo -e "${RED}Check logs: sudo journalctl -u $service${NC}"
fi
done
echo -e "\n${GREEN}AITBC services started!${NC}"
echo -e "Use '$0 stop' to stop all services"
echo -e "Use '$0 status' to check service status"
}
stop_services() {
echo -e "${BLUE}Stopping AITBC development services...${NC}"
for service in "${SERVICES[@]}"; do
if systemctl is-active --quiet "$service"; then
echo -e "Stopping $service..."
sudo systemctl stop "$service"
echo -e "${GREEN}$service stopped${NC}"
else
echo -e "${YELLOW}$service was not running${NC}"
fi
done
# Clean up PID file
rm -f "$PID_FILE"
echo -e "\n${GREEN}All AITBC services stopped${NC}"
}
show_status() {
echo -e "${BLUE}AITBC Service Status:${NC}\n"
for service in "${SERVICES[@]}"; do
if systemctl is-active --quiet "$service"; then
echo -e "${GREEN}$service: RUNNING${NC}"
# Show uptime
uptime=$(systemctl show "$service" --property=ActiveEnterTimestamp --value)
echo -e " Running since: $uptime"
else
echo -e "${RED}$service: STOPPED${NC}"
fi
done
# Show recent logs if any services are running
echo -e "\n${BLUE}Recent logs (last 10 lines each):${NC}"
for service in "${SERVICES[@]}"; do
if systemctl is-active --quiet "$service"; then
echo -e "\n${YELLOW}--- $service ---${NC}"
sudo journalctl -u "$service" -n 5 --no-pager | tail -n 5
fi
done
}
show_logs() {
local service="$1"
if [ -z "$service" ]; then
echo -e "${BLUE}Following logs for all AITBC services...${NC}"
sudo journalctl -f -u aitbc-blockchain-node.service -u aitbc-blockchain-rpc.service -u aitbc-gpu-miner.service -u aitbc-mock-coordinator.service
else
echo -e "${BLUE}Following logs for $service...${NC}"
sudo journalctl -f -u "$service"
fi
}
restart_services() {
echo -e "${BLUE}Restarting AITBC services...${NC}"
stop_services
sleep 3
start_services
}
cleanup() {
echo -e "${BLUE}Performing cleanup...${NC}"
stop_services
# Additional cleanup
echo -e "Cleaning up temporary files..."
rm -f "$PROJECT_ROOT/.aitbc_dev_pids"
# Clear any lingering processes (optional)
echo -e "Checking for lingering processes..."
pkill -f "aitbc" || echo "No lingering processes found"
echo -e "${GREEN}Cleanup complete${NC}"
}
# Handle script interruption for Ctrl+C only
trap cleanup INT
# Main script logic
case "$1" in
start)
start_services
;;
stop)
stop_services
;;
restart)
restart_services
;;
status)
show_status
;;
logs)
show_logs "$2"
;;
cleanup)
cleanup
;;
*)
echo -e "${BLUE}AITBC Development Services Manager${NC}"
echo -e "\nUsage: $0 {start|stop|restart|status|logs|cleanup}"
echo -e "\nCommands:"
echo -e " start - Start all AITBC services"
echo -e " stop - Stop all AITBC services"
echo -e " restart - Restart all AITBC services"
echo -e " status - Show service status"
echo -e " logs - Follow logs (optional: specify service name)"
echo -e " cleanup - Stop services and clean up"
echo -e "\nExamples:"
echo -e " $0 start # Start all services"
echo -e " $0 logs # Follow all logs"
echo -e " $0 logs node # Follow node logs only"
echo -e " $0 stop # Stop all services"
exit 1
;;
esac

View File

@@ -0,0 +1,98 @@
#!/bin/bash
# AITBC Service Management Script
case "$1" in
status)
echo "=== AITBC Service Status ==="
for service in aitbc-coordinator-api aitbc-exchange-api aitbc-exchange-frontend aitbc-wallet aitbc-node; do
status=$(sudo systemctl is-active $service 2>/dev/null || echo "inactive")
enabled=$(sudo systemctl is-enabled $service 2>/dev/null || echo "disabled")
echo "$service: $status ($enabled)"
done
;;
start)
echo "Starting AITBC services..."
sudo systemctl start aitbc-coordinator-api
sudo systemctl start aitbc-exchange-api
sudo systemctl start aitbc-exchange-frontend
sudo systemctl start aitbc-wallet
sudo systemctl start aitbc-node
echo "Done!"
;;
stop)
echo "Stopping AITBC services..."
sudo systemctl stop aitbc-coordinator-api
sudo systemctl stop aitbc-exchange-api
sudo systemctl stop aitbc-exchange-frontend
sudo systemctl stop aitbc-wallet
sudo systemctl stop aitbc-node
echo "Done!"
;;
restart)
echo "Restarting AITBC services..."
sudo systemctl restart aitbc-coordinator-api
sudo systemctl restart aitbc-exchange-api
sudo systemctl restart aitbc-exchange-frontend
sudo systemctl restart aitbc-wallet
sudo systemctl restart aitbc-node
echo "Done!"
;;
logs)
if [ -z "$2" ]; then
echo "Usage: $0 logs <service-name>"
echo "Available services: coordinator-api, exchange-api, exchange-frontend, wallet, node"
exit 1
fi
case "$2" in
coordinator-api) sudo journalctl -u aitbc-coordinator-api -f ;;
exchange-api) sudo journalctl -u aitbc-exchange-api -f ;;
exchange-frontend) sudo journalctl -u aitbc-exchange-frontend -f ;;
wallet) sudo journalctl -u aitbc-wallet -f ;;
node) sudo journalctl -u aitbc-node -f ;;
*) echo "Unknown service: $2" ;;
esac
;;
enable)
echo "Enabling AITBC services to start on boot..."
sudo systemctl enable aitbc-coordinator-api
sudo systemctl enable aitbc-exchange-api
sudo systemctl enable aitbc-exchange-frontend
sudo systemctl enable aitbc-wallet
sudo systemctl enable aitbc-node
echo "Done!"
;;
disable)
echo "Disabling AITBC services from starting on boot..."
sudo systemctl disable aitbc-coordinator-api
sudo systemctl disable aitbc-exchange-api
sudo systemctl disable aitbc-exchange-frontend
sudo systemctl disable aitbc-wallet
sudo systemctl disable aitbc-node
echo "Done!"
;;
*)
echo "Usage: $0 {status|start|stop|restart|logs|enable|disable}"
echo ""
echo "Commands:"
echo " status - Show status of all AITBC services"
echo " start - Start all AITBC services"
echo " stop - Stop all AITBC services"
echo " restart - Restart all AITBC services"
echo " logs - View logs for a specific service"
echo " enable - Enable services to start on boot"
echo " disable - Disable services from starting on boot"
echo ""
echo "Examples:"
echo " $0 status"
echo " $0 logs exchange-api"
exit 1
;;
esac

View File

@@ -0,0 +1,103 @@
#!/bin/bash
# scripts/move-to-right-folder.sh
echo "🔄 Moving files to correct folders..."
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Auto mode
AUTO_MODE=false
if [[ "$1" == "--auto" ]]; then
AUTO_MODE=true
fi
# Change to project root
cd "$(dirname "$0")/.."
# Function to move file with confirmation
move_file() {
local file="$1"
local target_dir="$2"
if [[ -f "$file" ]]; then
echo -e "${BLUE}📁 Moving '$file' to '$target_dir/'${NC}"
if [[ "$AUTO_MODE" == "true" ]]; then
mkdir -p "$target_dir"
mv "$file" "$target_dir/"
echo -e "${GREEN}✅ Moved automatically${NC}"
else
read -p "Move this file? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
mkdir -p "$target_dir"
mv "$file" "$target_dir/"
echo -e "${GREEN}✅ Moved${NC}"
else
echo -e "${YELLOW}⏭️ Skipped${NC}"
fi
fi
fi
}
# Function to move directory with confirmation
move_dir() {
local dir="$1"
local target_dir="$2"
if [[ -d "$dir" ]]; then
echo -e "${BLUE}📁 Moving directory '$dir' to '$target_dir/'${NC}"
if [[ "$AUTO_MODE" == "true" ]]; then
mkdir -p "$target_dir"
mv "$dir" "$target_dir/"
echo -e "${GREEN}✅ Moved automatically${NC}"
else
read -p "Move this directory? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
mkdir -p "$target_dir"
mv "$dir" "$target_dir/"
echo -e "${GREEN}✅ Moved${NC}"
else
echo -e "${YELLOW}⏭️ Skipped${NC}"
fi
fi
fi
}
# Move test files
for file in test_*.py test_*.sh run_mc_test.sh; do
move_file "$file" "dev/tests"
done
# Move development scripts
for file in patch_*.py fix_*.py simple_test.py; do
move_file "$file" "dev/scripts"
done
# Move multi-chain files
for file in MULTI_*.md; do
move_file "$file" "dev/multi-chain"
done
# Move environment directories
for dir in node_modules .venv cli_env; do
move_dir "$dir" "dev/env"
done
# Move cache directories
for dir in .pytest_cache .ruff_cache .vscode; do
move_dir "$dir" "dev/cache"
done
# Move configuration files
for file in .aitbc.yaml .aitbc.yaml.example .env.production .nvmrc .lycheeignore; do
move_file "$file" "config"
done
echo -e "${GREEN}🎉 File organization complete!${NC}"

View File

@@ -0,0 +1,70 @@
#!/bin/bash
# Setup AITBC Systemd Services
# Requirements: Python 3.11+, systemd, sudo access
echo "🔧 Setting up AITBC systemd services..."
# Validate Python version
echo "🐍 Checking Python version..."
if ! python3.11 --version >/dev/null 2>&1; then
echo "❌ Error: Python 3.11+ is required but not found"
echo " Please install Python 3.11+ and try again"
exit 1
fi
PYTHON_VERSION=$(python3.11 --version | cut -d' ' -f2)
echo "✅ Found Python $PYTHON_VERSION"
# Validate systemctl is available
if ! command -v systemctl >/dev/null 2>&1; then
echo "❌ Error: systemctl not found. This script requires systemd."
exit 1
fi
echo "✅ Systemd available"
# Copy service files
echo "📁 Copying service files..."
sudo cp systemd/aitbc-*.service /etc/systemd/system/
# Reload systemd daemon
echo "🔄 Reloading systemd daemon..."
sudo systemctl daemon-reload
# Stop existing processes
echo "⏹️ Stopping existing processes..."
pkill -f "coordinator-api" || true
pkill -f "simple_exchange_api.py" || true
pkill -f "server.py --port 3002" || true
pkill -f "wallet_daemon" || true
pkill -f "node.main" || true
# Enable services
echo "✅ Enabling services..."
sudo systemctl enable aitbc-coordinator-api.service
sudo systemctl enable aitbc-exchange-api.service
sudo systemctl enable aitbc-exchange-frontend.service
sudo systemctl enable aitbc-wallet.service
sudo systemctl enable aitbc-node.service
# Start services
echo "🚀 Starting services..."
sudo systemctl start aitbc-coordinator-api.service
sudo systemctl start aitbc-exchange-api.service
sudo systemctl start aitbc-exchange-frontend.service
sudo systemctl start aitbc-wallet.service
sudo systemctl start aitbc-node.service
# Check status
echo ""
echo "📊 Service Status:"
for service in aitbc-coordinator-api aitbc-exchange-api aitbc-exchange-frontend aitbc-wallet aitbc-node; do
status=$(sudo systemctl is-active $service)
echo " $service: $status"
done
echo ""
echo "📝 To view logs: sudo journalctl -u <service-name> -f"
echo "📝 To restart: sudo systemctl restart <service-name>"
echo "📝 To stop: sudo systemctl stop <service-name>"