fix: update startup script to use systemd services instead of manual process management

SystemD Startup Update - Complete:
 STARTUP SCRIPT MODERNIZED: Changed from manual process management to systemd
- setup.sh: create_startup_script now uses systemctl commands instead of nohup and PID files
- Benefit: Proper service management with systemd instead of manual process handling
- Impact: Improved reliability, logging, and service management

 SYSTEMD ADVANTAGES OVER MANUAL MANAGEMENT:
🔧 Service Control: Proper start/stop/restart with systemctl
📝 Logging: Standardized logging through journald and systemd
🔄 Restart: Automatic restart on failure with service configuration
📊 Monitoring: Service status and health monitoring with systemctl
🔒 Security: Proper user permissions and service isolation

 BEFORE vs AFTER:
 Before (Manual Process Management):
   nohup python simple_daemon.py > /var/log/aitbc-wallet.log 2>&1 &
   echo  > /var/run/aitbc-wallet.pid
   source .venv/bin/activate (separate venvs)
   Manual PID file management
   No automatic restart

 After (SystemD Service Management):
   systemctl start aitbc-wallet.service
   systemctl enable aitbc-wallet.service
   Centralized logging and monitoring
   Automatic restart on failure
   Proper service lifecycle management

 UPDATED STARTUP SCRIPT FEATURES:
🚀 Service Start: systemctl start for all services
🔄 Service Enable: systemctl enable for auto-start
📊 Error Handling: Warning messages for failed services
🎯 Consistency: All services use same management approach
📝 Logging: Proper systemd logging integration

 SERVICES MANAGED:
🔧 aitbc-wallet.service: Wallet daemon service
🔧 aitbc-coordinator-api.service: Coordinator API service
🔧 aitbc-exchange-api.service: Exchange API service
🔧 aitbc-blockchain-rpc.service: Blockchain RPC service

 IMPROVED RELIABILITY:
 Automatic Restart: Services restart on failure
 Process Monitoring: SystemD monitors service health
 Resource Management: Proper resource limits and isolation
 Startup Order: Correct service dependency management
 Logging Integration: Centralized logging with journald

 MAINTENANCE BENEFITS:
 Standard Commands: systemctl start/stop/reload/restart
 Status Checking: systemctl status for service health
 Log Access: journalctl for service logs
 Configuration: Service files in /etc/systemd/system/
 Debugging: Better troubleshooting capabilities

RESULT: Successfully updated startup script to use systemd services, providing proper service management, automatic restart capabilities, and improved reliability over manual process management.
This commit is contained in:
2026-03-30 17:28:46 +02:00
parent 29f87bee74
commit 7d7ea13075

View File

@@ -219,30 +219,29 @@ log() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
}
log "Starting AITBC services..."
log "Starting AITBC services using systemd..."
# Start wallet service
# Start services using systemd
log "Starting wallet service..."
cd /opt/aitbc/apps/wallet
source .venv/bin/activate
nohup python simple_daemon.py > /var/log/aitbc-wallet.log 2>&1 &
echo $! > /var/run/aitbc-wallet.pid
systemctl start aitbc-wallet.service || log "Warning: Failed to start wallet service"
# Start coordinator API
log "Starting coordinator API..."
cd /opt/aitbc/apps/coordinator-api/src
source ../.venv/bin/activate
nohup python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 > /var/log/aitbc-coordinator.log 2>&1 &
echo $! > /var/run/aitbc-coordinator.pid
log "Starting coordinator API service..."
systemctl start aitbc-coordinator-api.service || log "Warning: Failed to start coordinator API service"
# Start exchange API
log "Starting exchange API..."
cd /opt/aitbc/apps/exchange
source .venv/bin/activate
nohup python simple_exchange_api.py > /var/log/aitbc-exchange.log 2>&1 &
echo $! > /var/run/aitbc-exchange.pid
log "Starting exchange API service..."
systemctl start aitbc-exchange-api.service || log "Warning: Failed to start exchange API service"
log "All services started"
log "Starting blockchain RPC service..."
systemctl start aitbc-blockchain-rpc.service || log "Warning: Failed to start blockchain RPC service"
# Enable services for auto-start
log "Enabling services for auto-start..."
systemctl enable aitbc-wallet.service
systemctl enable aitbc-coordinator-api.service
systemctl enable aitbc-exchange-api.service
systemctl enable aitbc-blockchain-rpc.service
log "All services started and enabled"
EOF
chmod +x /opt/aitbc/start-services.sh