ncantu dde1ccbb07 fix: Improve .env loading and add backup/startup scripts
**Motivations:**
- Fix 401 error on anchorage API due to .env not being loaded correctly
- Fix 502 error on dashboard due to service not running
- Add backup script for mining keys and wallet descriptors
- Improve service management with startup scripts and systemd services

**Root causes:**
- dotenv.config() was called without explicit path, causing .env to be loaded from wrong directory
- Services were not started automatically, causing 502 errors
- No backup mechanism for critical keys and wallet data

**Correctifs:**
- Improved .env loading in api-anchorage/src/server.js with explicit path
- Improved .env loading in signet-dashboard/src/server.js with explicit path
- Added backups/ directory to .gitignore to prevent committing sensitive data
- Created export-backup.sh script for backing up mining keys and wallet descriptors

**Evolutions:**
- Added api-anchorage/start.sh script for proper service startup
- Added api-anchorage/anchorage-api.service systemd service file
- Added fixKnowledge/api-anchorage-401-error.md documentation
- Added fixKnowledge/dashboard-502-error.md documentation
- Updated mempool submodule

**Pages affectées:**
- .gitignore (added backups/)
- api-anchorage/src/server.js (improved .env loading)
- api-anchorage/start.sh (new)
- api-anchorage/anchorage-api.service (new)
- signet-dashboard/src/server.js (improved .env loading)
- export-backup.sh (new)
- fixKnowledge/api-anchorage-401-error.md (new)
- fixKnowledge/dashboard-502-error.md (new)
- mempool (submodule updated)
2026-01-24 03:17:48 +01:00

45 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Script de démarrage de l'API d'ancrage
# Auteur: Équipe 4NK
# Date: 2026-01-24
set -e
# Répertoire de l'API
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Vérifier que le fichier .env existe
if [[ ! -f .env ]]; then
echo "Erreur: Le fichier .env n'existe pas dans $SCRIPT_DIR"
echo "Copiez .env.example vers .env et configurez-le"
exit 1
fi
# Vérifier que Node.js est installé
if ! command -v node &> /dev/null; then
echo "Erreur: Node.js n'est pas installé"
exit 1
fi
# Vérifier que les dépendances sont installées
if [[ ! -d node_modules ]]; then
echo "Installation des dépendances..."
npm install
fi
# Charger les variables d'environnement depuis .env
export $(grep -v '^#' .env | xargs)
# Afficher les informations de démarrage (sans la clé API)
echo "=== Démarrage de l'API d'ancrage ==="
echo "Répertoire: $SCRIPT_DIR"
echo "Port: ${API_PORT:-3010}"
echo "Host: ${API_HOST:-0.0.0.0}"
echo "API Keys configurées: $(echo "$API_KEYS" | tr ',' '\n' | wc -l) clé(s)"
echo ""
# Démarrer l'API
exec node src/server.js