Persistenza dati e logging avanzato con UI e Unraid
- Aggiunto TradeHistoryService per persistenza trade/posizioni attive su disco (JSON, auto-save/restore) - Logging centralizzato (LoggingService) con livelli, categorie, simbolo e buffer circolare (500 log) - Nuova pagina Logs: monitoraggio real-time, filtri avanzati, cancellazione log, colorazione livelli - Sezione "Dati Persistenti" in Settings: conteggio trade, dimensione dati, reset con conferma modale - Background service per salvataggio sicuro su shutdown/stop container - Aggiornata sidebar, stili modali/bottoni danger, .gitignore e documentazione (README, CHANGELOG, UNRAID_INSTALL, checklist) - Versione 1.3.0
This commit is contained in:
@@ -59,9 +59,13 @@ wget -O /boot/config/plugins/dockerMan/templates-user/TradingBot.xml \
|
||||
- La porta CONTAINER rimane sempre 8080 (non modificare)
|
||||
- Alternative comuni se 8888 occupata: `8881`, `9999`, `7777`
|
||||
|
||||
**Volume Dati**:
|
||||
**Volume Dati** (?? IMPORTANTE per persistenza!):
|
||||
- **AppData**: `/mnt/user/appdata/tradingbot` (già impostato)
|
||||
- Puoi cambiare se preferisci altra directory
|
||||
- Questo volume salva:
|
||||
- Trade history (`trade-history.json`)
|
||||
- Posizioni attive (`active-positions.json`)
|
||||
- Settings applicazione (`settings.json`)
|
||||
- ? I dati sopravvivono a restart/update del container
|
||||
|
||||
**Variabili Ambiente** (Avanzate - espandi se necessario):
|
||||
- **ASPNETCORE_ENVIRONMENT**: `Production` (non modificare)
|
||||
@@ -74,7 +78,7 @@ Unraid far
|
||||
- ? Pull immagine da Gitea Registry
|
||||
- ? Crea container con nome "TradingBot"
|
||||
- ? Configura porta WebUI (default 8888 ? host, 8080 ? container)
|
||||
- ? Crea volume per persistenza dati
|
||||
- ? **Crea volume persistente per dati**
|
||||
- ? Start automatico
|
||||
|
||||
### Step 3: Accedi WebUI
|
||||
@@ -99,6 +103,57 @@ Dovresti vedere la **Dashboard TradingBot**! ??
|
||||
|
||||
---
|
||||
|
||||
## ?? PERSISTENZA DATI
|
||||
|
||||
### Come Funziona
|
||||
|
||||
TradingBot salva automaticamente tutti i dati in `/app/data` dentro il container, che viene mappato sul volume host `/mnt/user/appdata/tradingbot`.
|
||||
|
||||
**File salvati automaticamente**:
|
||||
```
|
||||
/mnt/user/appdata/tradingbot/
|
||||
??? trade-history.json # Storia completa trade
|
||||
??? active-positions.json # Posizioni attualmente aperte
|
||||
??? settings.json # Impostazioni applicazione
|
||||
```
|
||||
|
||||
**Salvataggio automatico**:
|
||||
- ? Ogni 30 secondi (mentre bot running)
|
||||
- ?? Immediato dopo ogni trade eseguito
|
||||
- ?? On-stop quando fermi il bot
|
||||
- ?? Graceful shutdown su Docker stop/restart
|
||||
|
||||
### Benefici
|
||||
|
||||
? **Zero perdita dati** - Anche in caso di crash
|
||||
? **Restore automatico** - Stato ripristinato al riavvio
|
||||
? **Update sicuri** - Dati preservati durante aggiornamenti
|
||||
? **Backup facile** - Basta copiare la cartella appdata
|
||||
|
||||
### Backup Dati
|
||||
|
||||
```bash
|
||||
# Backup manuale
|
||||
tar -czf tradingbot-backup-$(date +%Y%m%d).tar.gz \
|
||||
/mnt/user/appdata/tradingbot
|
||||
|
||||
# Restore
|
||||
tar -xzf tradingbot-backup-20241221.tar.gz \
|
||||
-C /mnt/user/appdata/
|
||||
```
|
||||
|
||||
### Gestione Dati (via WebUI)
|
||||
|
||||
Vai su **Settings** ? **Dati Persistenti**:
|
||||
- Visualizza numero trade salvati
|
||||
- Visualizza dimensione dati
|
||||
- Visualizza posizioni attive
|
||||
- **Cancella tutti i dati** (con conferma)
|
||||
|
||||
?? **Nota**: Puoi cancellare i dati solo se il bot è fermo.
|
||||
|
||||
---
|
||||
|
||||
## ?? METODO 2: Installazione Manuale
|
||||
|
||||
Se preferisci non usare template:
|
||||
@@ -119,19 +174,21 @@ gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
|
||||
|
||||
**Console shell command**: `Shell`
|
||||
|
||||
### Step 3: Port Mapping
|
||||
### Step 3: Port Mapping (?? CRITICO!)
|
||||
|
||||
Click **Add another Path, Port, Variable, Label or Device**
|
||||
|
||||
**Config Type**: `Port`
|
||||
- **Name**: `WebUI`
|
||||
- **Container Port**: `8080`
|
||||
- **Host Port**: `8080` ? **Cambia questa se occupata!**
|
||||
- **Host Port**: `8888` ? **Cambia questa se occupata!**
|
||||
- **Connection Type**: `TCP`
|
||||
|
||||
### Step 4: Volume Mapping
|
||||
?? **Se questo mapping non viene configurato, la WebUI non sarà accessibile!**
|
||||
|
||||
Click **Add another Path, Port, Variable, Label or Device**
|
||||
### Step 4: Volume Mapping (?? IMPORTANTE per persistenza!)
|
||||
|
||||
Click **Add another Path, Port, Variable, Label o Device**
|
||||
|
||||
**Config Type**: `Path`
|
||||
- **Name**: `AppData`
|
||||
@@ -153,14 +210,7 @@ Click **Add another Path, Port, Variable, Label or Device**
|
||||
- **Name**: `TZ`
|
||||
- **Value**: `Europe/Rome` (o tuo timezone)
|
||||
|
||||
### Step 6: Health Check (Opzionale ma Consigliato)
|
||||
|
||||
**Extra Parameters**:
|
||||
```
|
||||
--health-cmd="wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1" --health-interval=30s --health-timeout=3s --health-retries=3 --health-start-period=40s
|
||||
```
|
||||
|
||||
### Step 7: Apply
|
||||
### Step 6: Apply
|
||||
|
||||
Click **Apply** in fondo alla pagina.
|
||||
|
||||
@@ -179,9 +229,11 @@ Click **Apply** in fondo alla pagina.
|
||||
Unraid farà:
|
||||
- ? Pull ultima immagine da Gitea
|
||||
- ? Ricrea container con nuova immagine
|
||||
- ? Mantiene dati persistenti (volume non viene toccato)
|
||||
- ? **Mantiene dati persistenti** (volume non viene toccato)
|
||||
- ? Mantiene configurazione (porta, variabili, etc.)
|
||||
|
||||
?? **I tuoi trade e impostazioni sono al sicuro durante gli update!**
|
||||
|
||||
### Automatico con User Scripts Plugin
|
||||
|
||||
Installa **User Scripts** plugin:
|
||||
@@ -391,3 +443,124 @@ https://tradingbot.tuo-dominio.com
|
||||
```
|
||||
|
||||
?? **Nota**: Il reverse proxy si connette alla porta HOST (8888), non container (8080)
|
||||
|
||||
---
|
||||
|
||||
## ?? SICUREZZA
|
||||
|
||||
### Best Practices
|
||||
|
||||
? **Porta non esposta pubblicamente** (solo LAN o VPN)
|
||||
? **Volume dati protetto** (`/mnt/user/appdata/tradingbot/`)
|
||||
? **Registry privato** (Gitea richiede login)
|
||||
? **Certificati validi** (Tailscale)
|
||||
? **User non-root** (già configurato nel Dockerfile)
|
||||
? **Dati persistenti** backup-ready
|
||||
|
||||
---
|
||||
|
||||
## ?? CHECKLIST INSTALLAZIONE
|
||||
|
||||
### Pre-Install
|
||||
- [ ] Unraid 6.10+ installato
|
||||
- [ ] Docker service attivo
|
||||
- [ ] Porta 8888 (o alternativa) disponibile
|
||||
- [ ] `docker login gitea.encke-hake.ts.net` successful
|
||||
- [ ] Internet attivo per pull immagine
|
||||
|
||||
### Install
|
||||
- [ ] Template XML scaricato su Unraid
|
||||
- [ ] Container creato da template
|
||||
- [ ] Porta WebUI configurata (8888 host ? 8080 container)
|
||||
- [ ] Volume AppData creato (`/mnt/user/appdata/tradingbot`)
|
||||
- [ ] Container status: **running**
|
||||
|
||||
### Post-Install
|
||||
- [ ] WebUI accessibile (http://IP:8888)
|
||||
- [ ] Dashboard carica correttamente
|
||||
- [ ] Settings modificabili e salvabili
|
||||
- [ ] Bot avviabile dalla UI
|
||||
- [ ] Trade vengono salvati automaticamente
|
||||
- [ ] Dati persistono dopo restart
|
||||
|
||||
---
|
||||
|
||||
## ?? VANTAGGI UNRAID NATIVO
|
||||
|
||||
? **Zero dipendenze** (no Portainer, no docker-compose)
|
||||
? **WebUI Unraid integrata** (gestione familiare)
|
||||
? **Auto-start** (container parte con Unraid)
|
||||
? **Backup integrato** (con plugin CA)
|
||||
? **Update semplice** (2 click: Stop ? Update ? Start)
|
||||
? **Template riutilizzabile** (reinstall in 1 minuto)
|
||||
? **Dati persistenti** (trade e settings sopravvivono)
|
||||
? **Logs accessibili** dalla UI
|
||||
|
||||
---
|
||||
|
||||
## ?? WORKFLOW COMPLETO
|
||||
|
||||
### Sviluppo (PC)
|
||||
```
|
||||
1. ?? Visual Studio ? Codice
|
||||
2. ?? Build ? Publish (Docker profile)
|
||||
3. ? Automatico: Push Gitea Registry
|
||||
?? Tags: latest, 1.2.0, 1.2.0-YYYYMMDD
|
||||
4. ?? git push origin main --tags
|
||||
```
|
||||
|
||||
### Deploy (Unraid)
|
||||
```
|
||||
1. ?? Docker tab ? TradingBot
|
||||
2. ?? Stop
|
||||
3. ?? Force Update (pull latest)
|
||||
4. ?? Start
|
||||
5. ? Done! (~ 1 minuto)
|
||||
?? Dati automaticamente ripristinati
|
||||
```
|
||||
|
||||
**Tempo totale**: ~2 minuti dal commit al running!
|
||||
|
||||
---
|
||||
|
||||
## ?? RISORSE
|
||||
|
||||
### Links Utili
|
||||
|
||||
| Risorsa | URL |
|
||||
|---------|-----|
|
||||
| **Template XML** | `https://gitea.encke-hake.ts.net/Alby96/Encelado/raw/branch/main/TradingBot/deployment/unraid-template.xml` |
|
||||
| **Repository Git** | `https://gitea.encke-hake.ts.net/Alby96/Encelado` |
|
||||
| **Docker Image** | `gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest` |
|
||||
| **Packages** | `https://gitea.encke-hake.ts.net/Alby96/Encelado/-/packages` |
|
||||
| **Support/Issues** | `https://gitea.encke-hake.ts.net/Alby96/Encelado/issues` |
|
||||
|
||||
### Comandi Utili
|
||||
|
||||
```bash
|
||||
# Status container
|
||||
docker ps -a | grep TradingBot
|
||||
|
||||
# Logs real-time
|
||||
docker logs -f TradingBot
|
||||
|
||||
# Statistics
|
||||
docker stats TradingBot --no-stream
|
||||
|
||||
# Restart
|
||||
docker restart TradingBot
|
||||
|
||||
# Update
|
||||
docker pull gitea.encke-hake.ts.net/alby96/encelado/tradingbot:latest
|
||||
|
||||
# Remove (mantiene dati in /mnt/user/appdata/tradingbot)
|
||||
docker rm -f TradingBot
|
||||
|
||||
# Inspect persistent data
|
||||
ls -lh /mnt/user/appdata/tradingbot/
|
||||
cat /mnt/user/appdata/tradingbot/trade-history.json | jq
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**?? TradingBot v1.2.0 con persistenza completa pronto su Unraid!**
|
||||
|
||||
Reference in New Issue
Block a user