feat: Complete ATLAS system installation and API fixes

## Backend Changes
- Add new API endpoints: combustible, pois, mantenimiento, video, configuracion
- Fix vehiculos endpoint to return paginated response with items array
- Add /vehiculos/all endpoint for non-paginated list
- Add /geocercas/all endpoint
- Add /alertas/configuracion GET/PUT endpoints
- Add /viajes/activos and /viajes/iniciar endpoints
- Add /reportes/stats, /reportes/templates, /reportes/preview endpoints
- Add /conductores/all and /conductores/disponibles endpoints
- Update router.py to include all new modules

## Frontend Changes
- Fix authentication token handling (snake_case vs camelCase)
- Update vehiculosApi.listAll to use /vehiculos/all
- Fix FuelGauge component usage in Combustible page
- Fix chart component exports (named + default exports)
- Update API client for proper token refresh

## Infrastructure
- Rename services from ADAN to ATLAS
- Configure Cloudflare tunnel for atlas.consultoria-as.com
- Update systemd service files
- Configure PostgreSQL with TimescaleDB
- Configure Redis, Mosquitto, Traccar, MediaMTX

## Documentation
- Update installation guides
- Update API reference
- Rename all ADAN references to ATLAS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
ATLAS Admin
2026-01-25 03:04:23 +00:00
parent 0dfce3ce20
commit e59aa2a742
73 changed files with 4415 additions and 450 deletions

View File

@@ -1,6 +1,6 @@
# Solucion de Problemas
Guia para diagnosticar y resolver problemas comunes en ADAN.
Guia para diagnosticar y resolver problemas comunes en ATLAS.
## Diagnostico Rapido
@@ -8,10 +8,10 @@ Guia para diagnosticar y resolver problemas comunes en ADAN.
```bash
# Ver estado de todos los servicios
systemctl status adan-api adan-web traccar mediamtx cloudflared redis postgresql
systemctl status atlas-api atlas-web traccar mediamtx cloudflared redis postgresql
# Resumen rapido
for svc in adan-api adan-web traccar mediamtx cloudflared; do
for svc in atlas-api atlas-web traccar mediamtx cloudflared; do
echo "$svc: $(systemctl is-active $svc)"
done
```
@@ -20,10 +20,10 @@ done
```bash
# API Backend
journalctl -u adan-api -f
journalctl -u atlas-api -f
# Frontend
journalctl -u adan-web -f
journalctl -u atlas-web -f
# Traccar (GPS)
journalctl -u traccar -f
@@ -45,7 +45,7 @@ curl http://localhost:8000/api/v1/health
curl http://localhost:3000
# Base de datos
psql -U adan -d adan_db -c "SELECT 1"
psql -U atlas -d atlas_db -c "SELECT 1"
# Redis
redis-cli ping
@@ -64,12 +64,12 @@ redis-cli ping
1. Estado del tunnel de Cloudflare:
```bash
systemctl status cloudflared
cloudflared tunnel info adan
cloudflared tunnel info atlas
```
2. Estado del frontend:
```bash
systemctl status adan-web
systemctl status atlas-web
curl http://localhost:3000
```
@@ -90,17 +90,17 @@ systemctl restart cloudflared
**Verificar**:
```bash
systemctl status adan-api
systemctl status atlas-api
curl http://localhost:8000/api/v1/health
```
**Soluciones**:
```bash
# Reiniciar backend
systemctl restart adan-api
systemctl restart atlas-api
# Ver logs de error
journalctl -u adan-api -n 100 --no-pager
journalctl -u atlas-api -n 100 --no-pager
```
### Error de SSL/Certificado
@@ -186,7 +186,7 @@ curl http://localhost:8082/api/devices
**Verificar**:
```bash
# Ver ubicaciones recientes en DB
psql -U adan -d adan_db -c "
psql -U atlas -d atlas_db -c "
SELECT vehiculo_id, tiempo, lat, lng
FROM ubicaciones
ORDER BY tiempo DESC
@@ -210,7 +210,7 @@ psql -U adan -d adan_db -c "
**Verificar en el servidor**:
```bash
# Ver ultimas ubicaciones de apps
journalctl -u adan-api | grep "ubicacion" | tail -20
journalctl -u atlas-api | grep "ubicacion" | tail -20
```
### App no puede conectar al servidor
@@ -238,7 +238,7 @@ journalctl -u adan-api | grep "ubicacion" | tail -20
**En el servidor**:
```bash
# Ver logs de notificaciones
journalctl -u adan-api | grep "push\|notification"
journalctl -u atlas-api | grep "push\|notification"
```
---
@@ -284,21 +284,21 @@ ffprobe rtsp://usuario:password@IP_CAMARA/stream
1. Espacio en disco:
```bash
df -h /opt/adan/videos
df -h /opt/atlas/videos
```
2. Permisos:
```bash
ls -la /opt/adan/videos
ls -la /opt/atlas/videos
```
**Solucion**:
```bash
# Liberar espacio
find /opt/adan/videos -name "*.mp4" -mtime +30 -delete
find /opt/atlas/videos -name "*.mp4" -mtime +30 -delete
# Arreglar permisos
chown -R www-data:www-data /opt/adan/videos
chown -R www-data:www-data /opt/atlas/videos
```
---
@@ -312,7 +312,7 @@ chown -R www-data:www-data /opt/adan/videos
systemctl status postgresql
# Verificar que acepta conexiones
psql -U adan -d adan_db -c "SELECT 1"
psql -U atlas -d atlas_db -c "SELECT 1"
```
**Soluciones**:
@@ -329,7 +329,7 @@ journalctl -u postgresql -f
**Verificar**:
```bash
# Ver consultas lentas
psql -U adan -d adan_db -c "
psql -U atlas -d atlas_db -c "
SELECT pid, now() - pg_stat_activity.query_start AS duration, query
FROM pg_stat_activity
WHERE state != 'idle'
@@ -341,26 +341,26 @@ psql -U adan -d adan_db -c "
1. Ejecutar VACUUM:
```bash
psql -U adan -d adan_db -c "VACUUM ANALYZE;"
psql -U atlas -d atlas_db -c "VACUUM ANALYZE;"
```
2. Verificar indices:
```bash
psql -U adan -d adan_db -c "\di"
psql -U atlas -d atlas_db -c "\di"
```
### Disco lleno por ubicaciones
**Verificar**:
```bash
psql -U adan -d adan_db -c "
psql -U atlas -d atlas_db -c "
SELECT pg_size_pretty(pg_total_relation_size('ubicaciones'));
"
```
**Solucion**: Comprimir datos antiguos (TimescaleDB):
```bash
psql -U adan -d adan_db -c "
psql -U atlas -d atlas_db -c "
SELECT compress_chunk(c)
FROM show_chunks('ubicaciones', older_than => INTERVAL '7 days') c;
"
@@ -406,10 +406,10 @@ ps aux | grep uvicorn
1. Aumentar workers en el servicio:
```bash
# Editar /etc/systemd/system/adan-api.service
# Editar /etc/systemd/system/atlas-api.service
# Cambiar --workers 4 a --workers 8
systemctl daemon-reload
systemctl restart adan-api
systemctl restart atlas-api
```
2. Verificar conexiones a Redis:
@@ -429,7 +429,7 @@ redis-cli info clients
systemctl status mosquitto
# Suscribirse para ver mensajes
mosquitto_sub -h localhost -t "adan/mesh/#" -u mesh_gateway -P password
mosquitto_sub -h localhost -t "atlas/mesh/#" -u mesh_gateway -P password
```
**Verificar configuracion del gateway**:
@@ -441,7 +441,7 @@ mosquitto_sub -h localhost -t "adan/mesh/#" -u mesh_gateway -P password
**Verificar**:
```bash
journalctl -u adan-api | grep "meshtastic\|mesh"
journalctl -u atlas-api | grep "meshtastic\|mesh"
```
**Solucion**: Verificar que el servicio MQTT esta corriendo en el backend.
@@ -455,38 +455,38 @@ journalctl -u adan-api | grep "meshtastic\|mesh"
**Verificar**:
```bash
# Espacio en disco
df -h /opt/adan/backups
df -h /opt/atlas/backups
# Permisos
ls -la /opt/adan/scripts/backup.sh
ls -la /opt/atlas/scripts/backup.sh
```
**Ejecutar manualmente para ver errores**:
```bash
/opt/adan/scripts/backup.sh 2>&1 | tee /tmp/backup.log
/opt/atlas/scripts/backup.sh 2>&1 | tee /tmp/backup.log
```
### Restauracion falla
**Verificar integridad del backup**:
```bash
gunzip -t /opt/adan/backups/db_FECHA.sql.gz
gunzip -t /opt/atlas/backups/db_FECHA.sql.gz
```
**Restaurar paso a paso**:
```bash
# Parar servicios
systemctl stop adan-api
systemctl stop atlas-api
# Recrear base de datos
psql -U postgres -c "DROP DATABASE adan_db;"
psql -U postgres -c "CREATE DATABASE adan_db OWNER adan;"
psql -U postgres -c "DROP DATABASE atlas_db;"
psql -U postgres -c "CREATE DATABASE atlas_db OWNER atlas;"
# Restaurar
gunzip -c backup.sql.gz | psql -U adan -d adan_db
gunzip -c backup.sql.gz | psql -U atlas -d atlas_db
# Iniciar servicios
systemctl start adan-api
systemctl start atlas-api
```
---
@@ -495,7 +495,7 @@ systemctl start adan-api
```bash
# Estado general del sistema
systemctl status adan-api adan-web traccar mediamtx cloudflared
systemctl status atlas-api atlas-web traccar mediamtx cloudflared
# Uso de recursos
htop
@@ -503,7 +503,7 @@ df -h
free -h
# Logs en tiempo real
journalctl -u adan-api -f
journalctl -u atlas-api -f
# Conexiones activas
ss -tlnp
@@ -515,10 +515,10 @@ netstat -tlnp
curl -s http://localhost:8000/api/v1/health | jq
# Test de base de datos
psql -U adan -d adan_db -c "SELECT COUNT(*) FROM vehiculos;"
psql -U atlas -d atlas_db -c "SELECT COUNT(*) FROM vehiculos;"
# Ultimas ubicaciones
psql -U adan -d adan_db -c "
psql -U atlas -d atlas_db -c "
SELECT v.nombre, u.tiempo, u.lat, u.lng, u.velocidad
FROM ubicaciones u
JOIN vehiculos v ON u.vehiculo_id = v.id
@@ -527,7 +527,7 @@ psql -U adan -d adan_db -c "
"
# Alertas pendientes
psql -U adan -d adan_db -c "
psql -U atlas -d atlas_db -c "
SELECT COUNT(*) as pendientes FROM alertas WHERE atendida = false;
"
```
@@ -545,12 +545,12 @@ Si no puedes resolver el problema:
echo "=== FECHA ==="
date
echo "=== SERVICIOS ==="
systemctl status adan-api adan-web traccar mediamtx cloudflared
systemctl status atlas-api atlas-web traccar mediamtx cloudflared
echo "=== RECURSOS ==="
free -h
df -h
echo "=== LOGS RECIENTES ==="
journalctl -u adan-api -n 50 --no-pager
journalctl -u atlas-api -n 50 --no-pager
} > /tmp/diagnostico.txt
```