From 29ca768c5914a355ea67a12fa6d4bff8c49dc3a9 Mon Sep 17 00:00:00 2001 From: aitbc Date: Thu, 2 Apr 2026 13:32:22 +0200 Subject: [PATCH] feat: configure blockchain services on correct ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Blockchain Services Port Configuration - Blockchain HTTP API: Port 8005 (new service) - Blockchain RPC API: Port 8006 (moved from 8007) - Real Marketplace: Port 8009 (moved from 8006) ✅ New Services Created - aitbc-blockchain-http.service: HTTP API on port 8005 - blockchain_http_launcher.py: FastAPI launcher for blockchain - Updated environment file: rpc_bind_port=8006 ✅ Port Reorganization - Port 8005: Blockchain HTTP API (NEW) - Port 8006: Blockchain RPC API (moved from 8007) - Port 8009: Real Marketplace (moved from 8006) - Port 8007: Now free for future use ✅ Verification - Blockchain HTTP API: Responding on port 8005 - Blockchain RPC API: Responding on port 8006 - Real Marketplace: Running on port 8009 - All services properly configured and operational 🚀 Blockchain services now running on requested ports! --- .../services/blockchain_http_launcher.py | 39 ++++++++++++++++ systemd/aitbc-blockchain-http.service | 46 +++++++++++++++++++ systemd/aitbc-real-marketplace.service | 2 +- 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100755 production/services/blockchain_http_launcher.py create mode 100644 systemd/aitbc-blockchain-http.service diff --git a/production/services/blockchain_http_launcher.py b/production/services/blockchain_http_launcher.py new file mode 100755 index 00000000..bdd7f9eb --- /dev/null +++ b/production/services/blockchain_http_launcher.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +""" +Blockchain HTTP Service Launcher +""" + +import os +import sys + +# Add production services to path +sys.path.insert(0, '/opt/aitbc/production/services') + +# Import blockchain manager and create FastAPI app +from mining_blockchain import MultiChainManager +from fastapi import FastAPI + +app = FastAPI(title='AITBC Blockchain HTTP API') + +@app.get('/health') +async def health(): + return {'status': 'ok', 'service': 'blockchain-http', 'port': 8005} + +@app.get('/info') +async def info(): + manager = MultiChainManager() + return manager.get_all_chains_info() + +@app.get('/blocks') +async def blocks(): + manager = MultiChainManager() + return {'blocks': manager.get_all_chains_info()} + +if __name__ == '__main__': + import uvicorn + uvicorn.run( + app, + host='0.0.0.0', + port=int(os.getenv('BLOCKCHAIN_HTTP_PORT', 8005)), + log_level='info' + ) diff --git a/systemd/aitbc-blockchain-http.service b/systemd/aitbc-blockchain-http.service new file mode 100644 index 00000000..00eec9c5 --- /dev/null +++ b/systemd/aitbc-blockchain-http.service @@ -0,0 +1,46 @@ +[Unit] +Description=AITBC Blockchain HTTP API (Port 8005) +After=network.target aitbc-blockchain-node.service + +[Service] +Type=simple +User=root +Group=root +WorkingDirectory=/opt/aitbc +Environment=PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin +Environment=NODE_ID=aitbc +Environment=BLOCKCHAIN_HTTP_PORT=8005 +Environment=PYTHONPATH=/opt/aitbc/production/services +EnvironmentFile=/opt/aitbc/production/.env + +# Blockchain HTTP execution +ExecStart=/opt/aitbc/venv/bin/python /opt/aitbc/production/services/blockchain_http_launcher.py +ExecReload=/bin/kill -HUP $MAINPID +KillMode=mixed +TimeoutStopSec=10 + +# Production reliability +Restart=always +RestartSec=5 +StartLimitBurst=5 +StartLimitIntervalSec=60 + +# Production logging +StandardOutput=journal +StandardError=journal +SyslogIdentifier=aitbc-blockchain-http + +# Production security +NoNewPrivileges=true +ProtectSystem=strict +ProtectHome=true +ReadWritePaths=/opt/aitbc/production/data/blockchain /opt/aitbc/production/logs/blockchain + +# Production performance +LimitNOFILE=65536 +LimitNPROC=4096 +MemoryMax=1G +CPUQuota=25% + +[Install] +WantedBy=multi-user.target diff --git a/systemd/aitbc-real-marketplace.service b/systemd/aitbc-real-marketplace.service index 9c792b53..48d94948 100644 --- a/systemd/aitbc-real-marketplace.service +++ b/systemd/aitbc-real-marketplace.service @@ -9,7 +9,7 @@ Group=root WorkingDirectory=/opt/aitbc Environment=PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin Environment=NODE_ID=aitbc -Environment=REAL_MARKETPLACE_PORT=8006 +Environment=REAL_MARKETPLACE_PORT=8009 Environment=PYTHONPATH=/opt/aitbc/production/services EnvironmentFile=/opt/aitbc/production/.env