Files
ATLAS/deploy/README.md
FlotillasGPS Developer 51d78bacf4 FlotillasGPS - Sistema completo de monitoreo de flotillas GPS
Sistema completo para monitoreo y gestion de flotas de vehiculos con:
- Backend FastAPI con PostgreSQL/TimescaleDB
- Frontend React con TypeScript y TailwindCSS
- App movil React Native con Expo
- Soporte para dispositivos GPS, Meshtastic y celulares
- Video streaming en vivo con MediaMTX
- Geocercas, alertas, viajes y reportes
- Autenticacion JWT y WebSockets en tiempo real

Documentacion completa y guias de usuario incluidas.
2026-01-21 08:18:00 +00:00

265 lines
5.7 KiB
Markdown

# Deploy - Sistema de Flotillas
Scripts y configuraciones para desplegar el sistema de flotillas en produccion.
## Estructura
```
deploy/
├── proxmox/ # Crear VM en Proxmox VE
│ └── vm-setup.sh
├── scripts/ # Scripts de utilidad
│ ├── install.sh # Instalacion completa
│ ├── backup.sh # Backup automatico
│ ├── restore.sh # Restaurar backup
│ ├── update.sh # Actualizar aplicacion
│ ├── health-check.sh # Verificar salud
│ ├── status.sh # Estado del sistema
│ └── logs.sh # Visor de logs
├── services/ # Servicios systemd
│ ├── flotillas-api.service
│ ├── flotillas-web.service
│ ├── mediamtx.service
│ └── cloudflared.service
├── cloudflare/ # Configuracion tunnel
│ └── config.yml
├── traccar/ # Configuracion GPS
│ └── traccar.xml
├── mediamtx/ # Configuracion streaming
│ └── mediamtx.yml
└── postgres/ # Base de datos
└── init.sql
```
## Requisitos
- **SO**: Ubuntu 22.04 LTS
- **RAM**: Minimo 4GB (recomendado 8GB)
- **Disco**: Minimo 50GB SSD
- **CPU**: 4 cores
## Instalacion Rapida
### 1. En Proxmox (opcional)
```bash
# Crear VM automaticamente
./deploy/proxmox/vm-setup.sh --vmid 200 --name flotillas --memory 8192
```
### 2. En Ubuntu
```bash
# Clonar repositorio
git clone https://github.com/tuorg/flotillas.git /opt/flotillas
cd /opt/flotillas
# Ejecutar instalador
sudo ./deploy/scripts/install.sh
```
El instalador:
- Actualiza el sistema
- Instala PostgreSQL 15 + TimescaleDB + PostGIS
- Instala Redis
- Instala Python 3.11 y Node.js 20
- Instala Traccar GPS Server
- Instala MediaMTX para video
- Configura servicios systemd
- Configura firewall (solo puerto 5055 publico)
- Genera credenciales aleatorias
## Post-Instalacion
### Verificar estado
```bash
./deploy/scripts/status.sh
./deploy/scripts/health-check.sh
```
### Ver logs
```bash
./deploy/scripts/logs.sh api -f # API en tiempo real
./deploy/scripts/logs.sh traccar # Traccar GPS
./deploy/scripts/logs.sh all -f # Todos los servicios
```
### Configurar Cloudflare Tunnel
1. Instalar cloudflared:
```bash
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb -o cloudflared.deb
dpkg -i cloudflared.deb
```
2. Autenticarse:
```bash
cloudflared tunnel login
```
3. Crear tunnel:
```bash
cloudflared tunnel create flotillas
```
4. Configurar DNS:
```bash
cloudflared tunnel route dns flotillas flotillas.tudominio.com
```
5. Copiar config y habilitar servicio:
```bash
mkdir -p /etc/cloudflared
cp /opt/flotillas/deploy/cloudflare/config.yml /etc/cloudflared/
systemctl enable cloudflared
systemctl start cloudflared
```
## Mantenimiento
### Backup
```bash
# Backup manual
./deploy/scripts/backup.sh
# Backup completo (incluye archivos)
./deploy/scripts/backup.sh --full
# Backup y subir a S3
./deploy/scripts/backup.sh --upload
```
Backups automaticos: diariamente a las 3 AM (configurado por install.sh)
### Restaurar
```bash
# Listar backups disponibles
./deploy/scripts/restore.sh --list
# Restaurar ultimo backup
./deploy/scripts/restore.sh --latest
# Restaurar backup especifico
./deploy/scripts/restore.sh --db /var/backups/flotillas/daily/flotillas_20240115_db.sql.gz
```
### Actualizar
```bash
# Actualizar a ultima version
./deploy/scripts/update.sh
# Forzar actualizacion (descarta cambios locales)
./deploy/scripts/update.sh --force
# Solo actualizar backend
./deploy/scripts/update.sh --backend
```
## Servicios
| Servicio | Puerto | Descripcion |
|----------|--------|-------------|
| flotillas-api | 8000 | Backend FastAPI |
| flotillas-web | 3000 | Frontend |
| postgresql | 5432 | Base de datos |
| redis | 6379 | Cache |
| traccar | 5055 | GPS Server |
| mediamtx | 8554/8889/8888 | Video RTSP/WebRTC/HLS |
| mosquitto | 1883 | MQTT |
### Comandos systemd
```bash
# Estado
systemctl status flotillas-api
# Reiniciar
systemctl restart flotillas-api
# Logs
journalctl -u flotillas-api -f
# Habilitar/Deshabilitar
systemctl enable flotillas-api
systemctl disable flotillas-api
```
## Seguridad
- **Firewall**: Solo puerto 5055 (GPS) esta abierto
- **Acceso web**: Via Cloudflare Tunnel (HTTPS)
- **Base de datos**: Solo acceso local
- **Redis**: Autenticacion con password
- **Fail2ban**: Proteccion contra fuerza bruta
## Puertos
| Puerto | Uso | Acceso |
|--------|-----|--------|
| 22 | SSH | Firewall |
| 5055 | Traccar GPS | Publico |
| 3000 | Frontend | Tunnel |
| 8000 | API | Tunnel |
| 5432 | PostgreSQL | Local |
| 6379 | Redis | Local |
| 8554 | RTSP | Tunnel |
| 8889 | WebRTC | Tunnel |
| 8888 | HLS | Tunnel |
## Troubleshooting
### API no inicia
```bash
# Ver logs
journalctl -u flotillas-api -n 100
# Verificar puerto
ss -tlnp | grep 8000
# Verificar base de datos
psql -h localhost -U flotillas -d flotillas -c "SELECT 1"
```
### Traccar no recibe datos
```bash
# Verificar puerto GPS
ss -tlnp | grep 5055
# Ver logs Traccar
tail -f /opt/traccar/logs/tracker-server.log
# Probar conexion
nc -zv localhost 5055
```
### Problemas de memoria
```bash
# Ver uso de memoria por servicio
systemctl status flotillas-api --no-pager | grep Memory
# Reducir workers de API
# Editar /etc/systemd/system/flotillas-api.service
# Cambiar --workers 4 a --workers 2
systemctl daemon-reload
systemctl restart flotillas-api
```
## Credenciales
Las credenciales se generan durante la instalacion y se guardan en:
- `/root/flotillas-credentials.txt`
**IMPORTANTE**: Guardar en lugar seguro y eliminar el archivo despues.
## Soporte
Para soporte, crear un issue en el repositorio o contactar al equipo de desarrollo.