Initial commit: Homelab documentation
- infrastructure.md: Network topology, server overview, credentials - gsm.md: Gameserver Monitor detailed documentation - todo.md: Project roadmap and completed tasks - CLAUDE.md: AI assistant context - temp/: Frontend component backups 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
306
gsm.md
Normal file
306
gsm.md
Normal file
@@ -0,0 +1,306 @@
|
||||
# Gameserver Monitor (GSM) - Dokumentation
|
||||
|
||||
## Uebersicht
|
||||
|
||||
Der Gameserver Monitor ist eine Web-Applikation zur Ueberwachung und Verwaltung von Gameservern.
|
||||
|
||||
**URL:** https://monitor.dimension47.de
|
||||
**Server:** 192.168.2.30 (LXC Container)
|
||||
|
||||
---
|
||||
|
||||
## Architektur
|
||||
|
||||
```
|
||||
Browser
|
||||
|
|
||||
v
|
||||
+------------------+
|
||||
| nginx (Port 80) | Reverse Proxy
|
||||
+--------+---------+
|
||||
|
|
||||
+-----+-----+
|
||||
| |
|
||||
v v
|
||||
Frontend Backend
|
||||
(dist/) (Port 3000)
|
||||
| |
|
||||
| +-----+-----+
|
||||
| | | |
|
||||
| v v v
|
||||
| SQLite SSH RCON
|
||||
| | | |
|
||||
| | +-----+-----+
|
||||
| | | |
|
||||
| v v v
|
||||
| users.db .50 .51 .52
|
||||
| whitelist Facto MC VRis
|
||||
|
|
||||
+---> Prometheus (Port 9090)
|
||||
|
|
||||
v
|
||||
Grafana (Port 3001)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Komponente | Technologie |
|
||||
|------------|-------------|
|
||||
| Frontend | React 18 + Vite + TailwindCSS 4 + recharts |
|
||||
| Backend | Node.js 20 + Express |
|
||||
| Datenbank | SQLite (better-sqlite3) |
|
||||
| Auth | JWT + bcrypt |
|
||||
| Metrics | Prometheus + Node Exporter |
|
||||
| Dashboards | Grafana |
|
||||
| Reverse Proxy | nginx |
|
||||
|
||||
---
|
||||
|
||||
## Verzeichnisstruktur
|
||||
|
||||
```
|
||||
/opt/gameserver-monitor/
|
||||
|
|
||||
+-- backend/
|
||||
| +-- server.js # Express Server Entry
|
||||
| +-- config.json # Server-Konfiguration
|
||||
| +-- .env # JWT_SECRET
|
||||
| +-- package.json
|
||||
| |
|
||||
| +-- routes/
|
||||
| | +-- servers.js # /api/servers Endpoints
|
||||
| | +-- auth.js # /api/auth Endpoints
|
||||
| |
|
||||
| +-- services/
|
||||
| | +-- ssh.js # SSH-Verbindungen, Status, Uptime
|
||||
| | +-- rcon.js # RCON-Kommunikation
|
||||
| | +-- prometheus.js # Prometheus Queries
|
||||
| |
|
||||
| +-- middleware/
|
||||
| | +-- auth.js # JWT Middleware
|
||||
| |
|
||||
| +-- db/
|
||||
| +-- init.js # DB-Schema, Whitelist-Cache
|
||||
| +-- users.sqlite # User-Datenbank
|
||||
|
|
||||
+-- frontend/
|
||||
+-- src/
|
||||
| +-- main.jsx
|
||||
| +-- App.jsx
|
||||
| +-- api.js # API Client
|
||||
| |
|
||||
| +-- pages/
|
||||
| | +-- Dashboard.jsx
|
||||
| | +-- ServerDetail.jsx
|
||||
| |
|
||||
| +-- components/
|
||||
| | +-- ServerCard.jsx
|
||||
| | +-- MetricsChart.jsx
|
||||
| | +-- LoginModal.jsx
|
||||
| | +-- SettingsModal.jsx
|
||||
| | +-- UserManagement.jsx
|
||||
| |
|
||||
| +-- context/
|
||||
| +-- UserContext.jsx
|
||||
|
|
||||
+-- public/
|
||||
| +-- minecraft.png
|
||||
| +-- factorio.png
|
||||
| +-- vrising.png
|
||||
| +-- navbarlogograuer.png
|
||||
| +-- navbarlogoweiss.png
|
||||
|
|
||||
+-- dist/ # Build Output (wird von nginx served)
|
||||
+-- index.html
|
||||
+-- package.json
|
||||
+-- vite.config.js
|
||||
+-- tailwind.config.js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### Authentifizierung
|
||||
|
||||
| Method | Endpoint | Auth | Beschreibung |
|
||||
|--------|----------|------|--------------|
|
||||
| POST | /api/auth/login | - | Login, gibt JWT zurueck |
|
||||
| GET | /api/auth/me | JWT | Aktueller User + Rolle |
|
||||
| POST | /api/auth/change-password | JWT | Eigenes Passwort aendern |
|
||||
| GET | /api/auth/users | superadmin | Alle User auflisten |
|
||||
| POST | /api/auth/users | superadmin | Neuen User erstellen |
|
||||
| PATCH | /api/auth/users/:id/role | superadmin | Rolle aendern |
|
||||
| PATCH | /api/auth/users/:id/password | superadmin | Passwort setzen |
|
||||
| DELETE | /api/auth/users/:id | superadmin | User loeschen |
|
||||
|
||||
### Server
|
||||
|
||||
| Method | Endpoint | Auth | Beschreibung |
|
||||
|--------|----------|------|--------------|
|
||||
| GET | /api/servers | optional | Alle Server mit Status/Metrics |
|
||||
| GET | /api/servers/:id | optional | Einzelner Server |
|
||||
| POST | /api/servers/:id/start | moderator | Server starten |
|
||||
| POST | /api/servers/:id/stop | moderator | Server stoppen |
|
||||
| POST | /api/servers/:id/restart | moderator | Server neustarten |
|
||||
| GET | /api/servers/:id/logs | moderator | Console Logs |
|
||||
| POST | /api/servers/:id/rcon | moderator | RCON Befehl senden |
|
||||
| GET | /api/servers/:id/whitelist | optional | Whitelist (gecached) |
|
||||
| GET | /api/servers/:id/metrics/history | optional | Prometheus History |
|
||||
|
||||
---
|
||||
|
||||
## Rollensystem
|
||||
|
||||
| Rolle | Rechte |
|
||||
|-------|--------|
|
||||
| (kein Login) | Dashboard ansehen, Metriken sehen |
|
||||
| user | Wie ohne Login |
|
||||
| moderator | + Server starten/stoppen, Logs, RCON, Whitelist |
|
||||
| superadmin | + Nutzerverwaltung |
|
||||
|
||||
---
|
||||
|
||||
## Server-Konfiguration
|
||||
|
||||
`/opt/gameserver-monitor/backend/config.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"servers": [
|
||||
{
|
||||
"id": "minecraft",
|
||||
"name": "All the Mods 10 | Minecraft",
|
||||
"host": "192.168.2.51",
|
||||
"type": "minecraft",
|
||||
"runtime": "screen",
|
||||
"screenName": "minecraft",
|
||||
"workDir": "/opt/minecraft",
|
||||
"startCmd": "./run.sh",
|
||||
"rconPort": 25575,
|
||||
"rconPassword": "gsm-mc-2026"
|
||||
},
|
||||
{
|
||||
"id": "factorio",
|
||||
"name": "Factorio",
|
||||
"host": "192.168.2.50",
|
||||
"type": "factorio",
|
||||
"runtime": "docker",
|
||||
"containerName": "factorio",
|
||||
"rconPort": 27015,
|
||||
"rconPassword": "jieTig6IkixaKuu"
|
||||
},
|
||||
{
|
||||
"id": "vrising",
|
||||
"name": "V Rising",
|
||||
"host": "192.168.2.52",
|
||||
"type": "vrising",
|
||||
"runtime": "systemd",
|
||||
"serviceName": "vrising",
|
||||
"workDir": "/home/steam/vrising"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Runtime-Typen
|
||||
|
||||
| Runtime | Status-Check | Start | Stop | Uptime |
|
||||
|---------|--------------|-------|------|--------|
|
||||
| docker | docker inspect | docker start | docker stop | Container StartedAt |
|
||||
| screen | screen -ls | screen -dmS | screen -X quit | ps -o etimes |
|
||||
| systemd | systemctl is-active | systemctl start | systemctl stop | ActiveEnterTimestamp |
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
### Oeffentliches Dashboard
|
||||
- Dashboard ist ohne Login sichtbar
|
||||
- Login-Modal fuer Admins ueber "Sign in" Button
|
||||
- Alle Server-Karten sichtbar, aber ohne Admin-Hints
|
||||
|
||||
### Gameserver-Uptime
|
||||
- Zeigt Prozess-Uptime statt Host-Uptime
|
||||
- Docker: Container-Laufzeit
|
||||
- Screen: Session-Laufzeit
|
||||
- Systemd: Service-Aktivzeit
|
||||
|
||||
### Whitelist-Caching (Minecraft)
|
||||
- Whitelist wird serverseitig in SQLite gecached
|
||||
- Anzeige auch wenn Server offline
|
||||
- Bearbeitung nur wenn Server online
|
||||
- Cache wird bei jeder Aenderung aktualisiert
|
||||
|
||||
### Navbar-Logo
|
||||
- Grau (navbarlogograuer.png) im Normalzustand
|
||||
- Weiss (navbarlogoweiss.png) bei Hover
|
||||
- Weiche CSS-Transition (300ms)
|
||||
- Link zu https://zeasy.software
|
||||
|
||||
### Game-Logos
|
||||
- Automatische Erkennung anhand Server-Name
|
||||
- minecraft.png, factorio.png, vrising.png
|
||||
- Angezeigt in ServerCard und ServerDetail
|
||||
|
||||
---
|
||||
|
||||
## Wartung
|
||||
|
||||
### Backend neustarten
|
||||
```bash
|
||||
ssh root@192.168.2.30
|
||||
pkill -f 'node server.js'
|
||||
cd /opt/gameserver-monitor/backend
|
||||
node server.js &
|
||||
```
|
||||
|
||||
### Frontend neu bauen
|
||||
```bash
|
||||
ssh root@192.168.2.30
|
||||
cd /opt/gameserver-monitor/frontend
|
||||
npm run build
|
||||
nginx -s reload
|
||||
```
|
||||
|
||||
### Logs pruefen
|
||||
```bash
|
||||
# Backend (laeuft im Hintergrund)
|
||||
# Fehler werden auf stderr ausgegeben
|
||||
|
||||
# nginx
|
||||
tail -f /var/log/nginx/error.log
|
||||
tail -f /var/log/nginx/access.log
|
||||
```
|
||||
|
||||
### Neuen Server hinzufuegen
|
||||
1. config.json bearbeiten (siehe oben)
|
||||
2. SSH-Key auf neuem Server hinterlegen
|
||||
3. Node Exporter installieren (fuer Prometheus)
|
||||
4. Backend neustarten
|
||||
|
||||
### User verwalten
|
||||
- Ueber UI: Settings > Users (nur superadmin)
|
||||
- Direkt in DB: `/opt/gameserver-monitor/backend/db/users.sqlite`
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### 502 Bad Gateway
|
||||
- Backend laeuft nicht
|
||||
- Loesung: Backend manuell starten
|
||||
|
||||
### Server zeigt "offline" obwohl online
|
||||
- SSH-Verbindung fehlgeschlagen
|
||||
- Loesung: SSH-Key pruefen, Firewall pruefen
|
||||
|
||||
### Whitelist leer
|
||||
- RCON-Verbindung fehlgeschlagen
|
||||
- Loesung: RCON-Port und Passwort pruefen
|
||||
|
||||
### Metrics zeigen 0
|
||||
- Prometheus Target nicht erreichbar
|
||||
- Loesung: Node Exporter auf Gameserver pruefen
|
||||
Reference in New Issue
Block a user