# 🔧 Maintenance et Administration ## Commandes de Base ### DĂ©marrer l'application ```bash cd WebNationsGlory_ServeurBuild_Red ./start.sh ``` ### ArrĂȘter l'application ```bash # Ctrl+C dans le terminal ``` ### RedĂ©marrer l'application ```bash # 1. ArrĂȘtez avec Ctrl+C # 2. Relancez avec ./start.sh ``` ## DĂ©pannage ### VĂ©rifier l'Ă©tat de RCON ```bash # Test simple echo "status" | timeout 2 bash -c 'exec 3<>/dev/tcp/localhost/25575; cat >&3; cat <&3' 2>/dev/null || echo "RCON non accessible" # Avec nc (netcat) nc -w 2 localhost 25575 < /dev/null && echo "RCON OK" || echo "RCON KO" # Avec telnet telnet localhost 25575 ``` ### VĂ©rifier les logs du serveur MC ```bash # DerniĂšres 50 lignes tail -50 /path/to/mc-server/latest.log # Rechercher les erreurs grep ERROR /path/to/mc-server/latest.log # Suivre en temps rĂ©el tail -f /path/to/mc-server/latest.log ``` ### VĂ©rifier si le port 3000 est utilisĂ© ```bash # Linux/Mac lsof -i :3000 # Windows PowerShell Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess # Tuer le processus (Linux/Mac) kill -9 $(lsof -t -i :3000) ``` ### RĂ©initialiser Node.js ```bash cd backend # Supprimer node_modules rm -rf node_modules rm package-lock.json # RĂ©installer npm install # RedĂ©marrer npm start ``` ## Gestion des OPs ### Ajouter un OP sur le serveur MC ``` /op NomdujoueurMC ``` ### VĂ©rifier les OPs ```bash # Fichier ops.txt cat /path/to/mc-server/ops.txt # Ou ops.json (Minecraft 1.8+) cat /path/to/mc-server/ops.json ``` ## Backups ### CrĂ©er un backup manuel ```bash cd /path/to/mc-server # CrĂ©er un tar.gz du serveur tar -czf ../backup-$(date +%Y%m%d-%H%M%S).tar.gz . # Avec exclusion de certains fichiers tar -czf ../backup-$(date +%Y%m%d-%H%M%S).tar.gz \ --exclude='*.log' \ --exclude='cache' \ --exclude='.web-admin' \ . ``` ### Restaurer un backup ```bash # ArrĂȘter le serveur d'abord! ./stop.sh # Restaurer cd /backup/location tar -xzf backup-file.tar.gz -C /path/to/mc-server # RedĂ©marrer cd /path/to/mc-server ./start.sh ``` ## Logs et Monitoring ### Voir les logs backend en temps rĂ©el ```bash cd backend npm start ``` ### Voir les logs RCON (historique des commandes) ```bash cat /path/to/mc-server/.web-admin/rcon-history.json ``` ### Nettoyer les vieux logs ```bash # Supprimer les logs de plus de 30 jours find /path/to/mc-server -name "*.log" -mtime +30 -delete ``` ## Variables d'Environnement ### Changer le port ```env # backend/.env PORT=8080 ``` ### Changer le rĂ©pertoire du serveur ```env # backend/.env SERVER_DIR=/path/to/other/mc-server ``` ### Changer les identifiants RCON ```env # backend/.env RCON_HOST=192.168.1.100 RCON_PORT=25576 ``` ## Mise Ă  Jour des DĂ©pendances ### VĂ©rifier les mises Ă  jour disponibles ```bash cd backend npm outdated ``` ### Mettre Ă  jour les dĂ©pendances ```bash cd backend npm update ``` ### Mettre Ă  jour une dĂ©pendance spĂ©cifique ```bash cd backend npm install express@latest ``` ## SĂ©curitĂ© ### Changer le SESSION_SECRET ```bash # GĂ©nĂ©rer une nouvelle clĂ© node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" # Mettre Ă  jour dans backend/.env SESSION_SECRET= # RedĂ©marrer l'application ``` ### Changer le mot de passe RCON ```bash # Via l'interface web: Dashboard → Changer RCON # Ou Ă©diter manuellement server.properties: rcon.password=NewPassword123 # RedĂ©marrer le serveur MC ``` ## Performance ### VĂ©rifier l'utilisation mĂ©moire Node.js ```bash ps aux | grep node # Linux avec plus de dĂ©tails ps -eo pid,vsz,rss,comm | grep node ``` ### Nettoyer les fichiers temporaires ```bash cd backend rm -rf node_modules npm install ``` ## Troubleshooting ### L'application dĂ©marre mais l'interface ne charge pas ```bash # VĂ©rifier que le frontend est bien servi curl http://localhost:3000/ # Doit retourner l'HTML # VĂ©rifier la console du navigateur (F12) pour les erreurs ``` ### Les commandes RCON n'exĂ©cutent pas ```bash # VĂ©rifier que RCON est activĂ© grep "enable-rcon" /path/to/mc-server/server.properties # Doit ĂȘtre: enable-rcon=true # VĂ©rifier le mot de passe RCON grep "rcon.password" /path/to/mc-server/server.properties # Tester RCON directement echo "say Test" | nc localhost 25575 ``` ### Base de donnĂ©es de sessions corruptĂ©e ```bash # Supprimer les sessions rm -rf backend/sessions/* # RedĂ©marrer l'application ./start.sh ``` ## Commandes Minecraft Utiles ### Via la console web ``` /list # Liste les joueurs /say @a Message # Message Ă  tous /tp @p @s # TĂ©lĂ©porter /weather clear # MĂ©tĂ©o /time set day # Heure /gamerule # Game rules /difficulty 3 # DifficultĂ© /seed # Seed du monde /spawnpoint @p 0 100 0 # Spawnpoint ``` ## Scripts AutomatisĂ©s ### Script de backup automatique ```bash #!/bin/bash # save-mc-backup.sh SERVER_DIR="/path/to/mc-server" BACKUP_DIR="$SERVER_DIR/backups" mkdir -p "$BACKUP_DIR" DATE=$(date +%Y%m%d_%H%M%S) BACKUP_FILE="$BACKUP_DIR/backup_$DATE.tar.gz" cd "$SERVER_DIR" tar -czf "$BACKUP_FILE" \ --exclude='*.log' \ --exclude='cache' \ --exclude='.web-admin' \ . echo "Backup créé: $BACKUP_FILE" # À ajouter Ă  crontab: # 0 2 * * * /path/to/save-mc-backup.sh ``` ### Script de redĂ©marrage programmĂ© ```bash #!/bin/bash # restart-mc-server.sh echo "RedĂ©marrage du serveur MC dans 1 minute..." # Via RCON echo "say RedĂ©marrage dans 1 minute!" | nc localhost 25575 sleep 30 echo "say 30 secondes!" | nc localhost 25575 sleep 20 echo "say 10 secondes!" | nc localhost 25575 sleep 10 echo "stop" | nc localhost 25575 sleep 5 # RedĂ©marrer cd /path/to/mc-server ./start.sh ``` ## Monitoring ### VĂ©rifier l'espace disque ```bash # Espace utilisĂ© par le serveur du -sh /path/to/mc-server # Espace libre df -h /path/to/mc-server ``` ### VĂ©rifier les processus Node.js ```bash ps aux | grep node # Ou ps aux | grep npm ``` ### VĂ©rifier les ports en Ă©coute ```bash netstat -tlnp | grep 3000 # Node.js netstat -tlnp | grep 25575 # RCON netstat -tlnp | grep 25565 # Serveur MC ``` --- **💡 Astuce**: Sauvegardez ces commandes pour un accĂšs rapide!