Fixed CLI blockchain connection timeout errors by updating default RPC URL from port 8006 to port 8005 across all CLI modules. Root cause: - Port 8006 is for blockchain P2P protocol (not HTTP RPC) - Port 8005 is the HTTP RPC API port - CLI was trying to use HTTP on port 8006, causing timeouts Updated files: - cli/advanced_wallet.py: DEFAULT_RPC_URL - cli/enterprise_cli.py: DEFAULT_RPC_URL - cli/commands/blockchain.py: _get_node_endpoint() - cli/core/main.py: default_rpc_url - cli/commands/sync.py: source and import-url defaults - cli/commands/marketplace.py: rpc_url config default - cli/commands/blockchain_event_bridge.py: test mode config - cli/handlers/bridge.py: test mode config - cli/commands/deployment.py: service endpoints This fixes the training script errors where CLI commands were timing out when trying to connect to the blockchain node.
167 lines
4.7 KiB
Python
167 lines
4.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
AITBC CLI - Fixed version with inline system commands
|
|
"""
|
|
|
|
import click
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Import island-specific commands
|
|
from aitbc_cli.commands.gpu_marketplace import gpu
|
|
from aitbc_cli.commands.exchange_island import exchange_island
|
|
from aitbc_cli.commands.wallet import wallet
|
|
from aitbc_cli.commands.genesis import genesis
|
|
|
|
# Force version to 0.2.2
|
|
__version__ = "0.2.2"
|
|
|
|
@click.group()
|
|
def system():
|
|
"""System management commands"""
|
|
pass
|
|
|
|
@system.command()
|
|
def architect():
|
|
"""System architecture analysis"""
|
|
click.echo("=== AITBC System Architecture ===")
|
|
click.echo("✅ Data: /var/lib/aitbc/data")
|
|
click.echo("✅ Config: /etc/aitbc")
|
|
click.echo("✅ Logs: /var/log/aitbc")
|
|
click.echo("✅ Repository: Clean")
|
|
|
|
# Check actual directories
|
|
system_dirs = {
|
|
'/var/lib/aitbc/data': 'Data storage',
|
|
'/etc/aitbc': 'Configuration',
|
|
'/var/log/aitbc': 'Logs'
|
|
}
|
|
|
|
for dir_path, description in system_dirs.items():
|
|
if os.path.exists(dir_path):
|
|
click.echo(f"✅ {description}: {dir_path}")
|
|
else:
|
|
click.echo(f"❌ {description}: {dir_path} (missing)")
|
|
|
|
@system.command()
|
|
def audit():
|
|
"""Audit system compliance"""
|
|
click.echo("=== System Audit ===")
|
|
click.echo("FHS Compliance: ✅")
|
|
click.echo("Repository Clean: ✅")
|
|
click.echo("Service Health: ✅")
|
|
|
|
# Check repository cleanliness
|
|
repo_dirs = ['/var/lib/aitbc/data', '/etc/aitbc', '/var/log/aitbc']
|
|
clean = True
|
|
for dir_path in repo_dirs:
|
|
if os.path.exists(dir_path):
|
|
click.echo(f"❌ Repository contains: {dir_path}")
|
|
clean = False
|
|
|
|
if clean:
|
|
click.echo("✅ Repository clean of runtime directories")
|
|
|
|
@system.command()
|
|
@click.option('--service', help='Check specific service')
|
|
def check(service):
|
|
"""Check service configuration"""
|
|
click.echo(f"=== Service Check: {service or 'All Services'} ===")
|
|
|
|
if service:
|
|
service_file = f"/etc/systemd/system/aitbc-{service}.service"
|
|
if os.path.exists(service_file):
|
|
click.echo(f"✅ Service file exists: {service_file}")
|
|
else:
|
|
click.echo(f"❌ Service file missing: {service_file}")
|
|
else:
|
|
services = ['marketplace', 'mining-blockchain', 'openclaw-ai', 'blockchain-node']
|
|
for svc in services:
|
|
service_file = f"/etc/systemd/system/aitbc-{svc}.service"
|
|
if os.path.exists(service_file):
|
|
click.echo(f"✅ {svc}: {service_file}")
|
|
else:
|
|
click.echo(f"❌ {svc}: {service_file}")
|
|
|
|
@click.command()
|
|
def version():
|
|
"""Show version information"""
|
|
click.echo(f"aitbc, version {__version__}")
|
|
click.echo("System Architecture Support: ✅")
|
|
click.echo("FHS Compliance: ✅")
|
|
click.echo("New Features: ✅")
|
|
|
|
@click.group()
|
|
@click.option(
|
|
"--url",
|
|
default=None,
|
|
help="Coordinator API URL (overrides config)"
|
|
)
|
|
@click.option(
|
|
"--api-key",
|
|
default=None,
|
|
help="API key for authentication"
|
|
)
|
|
@click.option(
|
|
"--chain-id",
|
|
default=None,
|
|
help="Chain ID for multichain operations (e.g., ait-mainnet, ait-devnet)"
|
|
)
|
|
@click.option(
|
|
"--output",
|
|
default="table",
|
|
type=click.Choice(["table", "json", "yaml", "csv"]),
|
|
help="Output format"
|
|
)
|
|
@click.option(
|
|
"--verbose",
|
|
"-v",
|
|
count=True,
|
|
help="Increase verbosity (can be used multiple times)"
|
|
)
|
|
@click.option(
|
|
"--debug",
|
|
is_flag=True,
|
|
help="Enable debug mode"
|
|
)
|
|
@click.pass_context
|
|
def cli(ctx, url, api_key, chain_id, output, verbose, debug):
|
|
"""AITBC CLI - Command Line Interface for AITBC Network
|
|
|
|
Manage jobs, mining, wallets, blockchain operations, marketplaces, and AI
|
|
services.
|
|
|
|
SYSTEM ARCHITECTURE COMMANDS:
|
|
system System management commands
|
|
system architect System architecture analysis
|
|
system audit Audit system compliance
|
|
system check Check service configuration
|
|
|
|
Examples:
|
|
aitbc system architect
|
|
aitbc system audit
|
|
aitbc system check --service marketplace
|
|
"""
|
|
ctx.ensure_object(dict)
|
|
ctx.obj['url'] = url
|
|
ctx.obj['api_key'] = api_key
|
|
ctx.obj['output'] = output
|
|
ctx.obj['verbose'] = verbose
|
|
ctx.obj['debug'] = debug
|
|
|
|
# Handle chain_id with auto-detection
|
|
from aitbc_cli.utils.chain_id import get_chain_id, get_default_chain_id
|
|
default_rpc_url = url.replace('/api', '') if url else 'http://localhost:8005'
|
|
ctx.obj['chain_id'] = get_chain_id(default_rpc_url, override=chain_id)
|
|
|
|
# Add commands to CLI
|
|
cli.add_command(system)
|
|
cli.add_command(version)
|
|
cli.add_command(gpu)
|
|
cli.add_command(exchange_island)
|
|
cli.add_command(wallet)
|
|
cli.add_command(genesis)
|
|
|
|
if __name__ == '__main__':
|
|
cli()
|