feat: move data directory from repository to system location

 Data Directory Restructure
- Moved /opt/aitbc/data to /var/lib/aitbc/data (proper system location)
- Updated all production services to use system data path
- Updated systemd services to use system data path
- Created symlink for backward compatibility
- Created proper data directories in /var/lib/aitbc/data/

 Services Updated
- Marketplace: /var/lib/aitbc/data/marketplace
- Blockchain: /var/lib/aitbc/data/blockchain
- OpenClaw: /var/lib/aitbc/data/openclaw
- All services now using system data paths

 System Compliance
- Data stored in /var/lib/aitbc (FHS compliant)
- Repository no longer contains runtime data
- Backward compatibility maintained with symlink
- Production services using correct system paths

🚀 AITBC now follows proper system data directory structure!
This commit is contained in:
aitbc
2026-04-02 13:45:14 +02:00
parent bc7aba23a0
commit 7de29c55fc
17 changed files with 19 additions and 18 deletions

1
data Symbolic link
View File

@@ -0,0 +1 @@
/var/lib/aitbc/data

View File

@@ -34,7 +34,7 @@ class ProductionBlockchain:
def __init__(self, node_id: str):
self.node_id = node_id
self.data_dir = Path(f'/opt/aitbc/production/data/blockchain/{node_id}')
self.data_dir = Path(f'/var/lib/aitbc/data/blockchain/{node_id}')
self.data_dir.mkdir(parents=True, exist_ok=True)
# Initialize blockchain

View File

@@ -81,7 +81,7 @@ class ProductionBlockchain:
def __init__(self, node_id: str):
self.node_id = node_id
self.data_dir = Path(f'/opt/aitbc/production/data/blockchain/{node_id}')
self.data_dir = Path(f'/var/lib/aitbc/data/blockchain/{node_id}')
self.data_dir.mkdir(parents=True, exist_ok=True)
# Initialize blockchain

View File

@@ -54,7 +54,7 @@ class ProductionMarketplace:
"""Production-grade marketplace with persistence"""
def __init__(self):
self.data_dir = Path('/opt/aitbc/production/data/marketplace')
self.data_dir = Path("/var/lib/aitbc/data/marketplace")
self.data_dir.mkdir(parents=True, exist_ok=True)
# Load existing data

View File

@@ -54,7 +54,7 @@ class ProductionMarketplace:
"""Production-grade marketplace with persistence"""
def __init__(self):
self.data_dir = Path('/opt/aitbc/production/data/marketplace')
self.data_dir = Path('/var/lib/aitbc/data/marketplace')
self.data_dir.mkdir(parents=True, exist_ok=True)
# Load existing data

View File

@@ -61,7 +61,7 @@ class MultiChainManager:
self.chains = {}
self.miners = {}
self.node_id = os.getenv('NODE_ID', 'aitbc')
self.data_dir = Path(f'/opt/aitbc/production/data/blockchain/{self.node_id}')
self.data_dir = Path(f'/var/lib/aitbc/data/blockchain/{self.node_id}')
self.data_dir.mkdir(parents=True, exist_ok=True)
# Initialize multiple chains

View File

@@ -30,7 +30,7 @@ class OpenClawAIService:
def __init__(self):
self.node_id = os.getenv('NODE_ID', 'aitbc')
self.data_dir = Path(f'/opt/aitbc/production/data/openclaw/{self.node_id}')
self.data_dir = Path(f'/var/lib/aitbc/data/openclaw/{self.node_id}')
self.data_dir.mkdir(parents=True, exist_ok=True)
# Initialize OpenClaw agents

View File

@@ -35,7 +35,7 @@ class RealMarketplace:
def __init__(self):
self.node_id = os.getenv('NODE_ID', 'aitbc')
self.data_dir = Path(f'/opt/aitbc/production/data/marketplace/{self.node_id}')
self.data_dir = Path(f'/var/lib/aitbc/data/marketplace/{self.node_id}')
self.data_dir.mkdir(parents=True, exist_ok=True)
# Initialize services

View File

@@ -86,7 +86,7 @@ class UnifiedMarketplace:
def __init__(self):
self.node_id = os.getenv('NODE_ID', 'aitbc')
self.data_dir = Path(f'/opt/aitbc/production/data/marketplace/{self.node_id}')
self.data_dir = Path(f'/var/lib/aitbc/data/marketplace/{self.node_id}')
self.data_dir.mkdir(parents=True, exist_ok=True)
# Initialize OpenClaw service if available

View File

@@ -34,7 +34,7 @@ SyslogIdentifier=aitbc-blockchain-http
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/aitbc/production/data/blockchain /opt/aitbc/production/logs/blockchain
ReadWritePaths=/var/lib/aitbc/data/blockchain /opt/aitbc/production/logs/blockchain
# Production performance
LimitNOFILE=65536

View File

@@ -34,7 +34,7 @@ SyslogIdentifier=aitbc-blockchain-production
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/aitbc/production/data/blockchain /opt/aitbc/production/logs/blockchain
ReadWritePaths=/var/lib/aitbc/data/blockchain /opt/aitbc/production/logs/blockchain
# Production performance
LimitNOFILE=65536

View File

@@ -34,7 +34,7 @@ SyslogIdentifier=aitbc-gpu-marketplace-production
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/aitbc/production/data/marketplace /opt/aitbc/production/logs/marketplace
ReadWritePaths=/var/lib/aitbc/data/marketplace /opt/aitbc/production/logs/marketplace
# Production performance
LimitNOFILE=65536

View File

@@ -16,7 +16,7 @@ Environment=PYTHONPATH=/opt/aitbc/production/services
EnvironmentFile=/opt/aitbc/production/.env
# Production execution
ExecStart=/opt/aitbc/venv/bin/python /opt/aitbc/production/services/unified_marketplace_launcher.py
ExecStart=/opt/aitbc/venv/bin/python /opt/aitbc/production/services/marketplace.py
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
TimeoutStopSec=10
@@ -36,7 +36,7 @@ SyslogIdentifier=aitbc-marketplace-production
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/aitbc/production/data/marketplace /opt/aitbc/production/logs/marketplace
ReadWritePaths=/var/lib/aitbc/data/marketplace /opt/aitbc/production/logs/marketplace
# Production performance
LimitNOFILE=65536

View File

@@ -33,7 +33,7 @@ SyslogIdentifier=aitbc-mining-blockchain
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/aitbc/production/data/blockchain /opt/aitbc/production/logs/blockchain
ReadWritePaths=/var/lib/aitbc/data/blockchain /opt/aitbc/production/logs/blockchain
# Mining performance
LimitNOFILE=65536

View File

@@ -33,7 +33,7 @@ SyslogIdentifier=aitbc-openclaw-ai
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/aitbc/production/data/openclaw /opt/aitbc/production/logs/openclaw
ReadWritePaths=/var/lib/aitbc/data/openclaw /opt/aitbc/production/logs/openclaw
# AI performance
LimitNOFILE=65536

View File

@@ -13,7 +13,7 @@ Environment=PYTHONPATH=/opt/aitbc/production/services
EnvironmentFile=/opt/aitbc/production/.env
# Production monitoring
ExecStart=/opt/aitbc/venv/bin/python -c "import time; import logging; import json; from pathlib import Path; logging.basicConfig(level=logging.INFO); logger = logging.getLogger('production-monitor'); while True: try: blockchain_file = Path('/opt/aitbc/production/data/blockchain/aitbc/blockchain.json'); if blockchain_file.exists(): with open(blockchain_file, 'r') as f: data = json.load(f); logger.info(f'Blockchain: {len(data.get(\"blocks\", []))} blocks'); marketplace_dir = Path('/opt/aitbc/production/data/marketplace'); if marketplace_dir.exists(): listings_file = marketplace_dir / 'gpu_listings.json'; if listings_file.exists(): with open(listings_file, 'r') as f: listings = json.load(f); logger.info(f'Marketplace: {len(listings)} GPU listings'); import psutil; cpu_percent = psutil.cpu_percent(); memory_percent = psutil.virtual_memory().percent; logger.info(f'System: CPU {cpu_percent}%, Memory {memory_percent}%'); time.sleep(30); except Exception as e: logger.error(f'Monitoring error: {e}'); time.sleep(60)"
ExecStart=/opt/aitbc/venv/bin/python -c "import time; import logging; import json; from pathlib import Path; logging.basicConfig(level=logging.INFO); logger = logging.getLogger('production-monitor'); while True: try: blockchain_file = Path('/var/lib/aitbc/data/blockchain/aitbc/blockchain.json'); if blockchain_file.exists(): with open(blockchain_file, 'r') as f: data = json.load(f); logger.info(f'Blockchain: {len(data.get(\"blocks\", []))} blocks'); marketplace_dir = Path('/var/lib/aitbc/data/marketplace'); if marketplace_dir.exists(): listings_file = marketplace_dir / 'gpu_listings.json'; if listings_file.exists(): with open(listings_file, 'r') as f: listings = json.load(f); logger.info(f'Marketplace: {len(listings)} GPU listings'); import psutil; cpu_percent = psutil.cpu_percent(); memory_percent = psutil.virtual_memory().percent; logger.info(f'System: CPU {cpu_percent}%, Memory {memory_percent}%'); time.sleep(30); except Exception as e: logger.error(f'Monitoring error: {e}'); time.sleep(60)"
# Production reliability
Restart=always
@@ -28,7 +28,7 @@ SyslogIdentifier=aitbc-production-monitor
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/aitbc/production/data /opt/aitbc/production/logs
ReadWritePaths=/var/lib/aitbc/data /opt/aitbc/production/logs
[Install]
WantedBy=multi-user.target

View File

@@ -34,7 +34,7 @@ SyslogIdentifier=aitbc-real-marketplace
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/aitbc/production/data/marketplace /opt/aitbc/production/logs/marketplace
ReadWritePaths=/var/lib/aitbc/data/marketplace /opt/aitbc/production/logs/marketplace
# Marketplace performance
LimitNOFILE=65536