- docs/PROYECTO_COMPLETO.md: v1.2, SMTP STARTTLS documentado - docs/DIARIO_DESARROLLO.md: Sesión 3 con migración Zig 0.15 y SMTP 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
142 lines
4.2 KiB
Markdown
142 lines
4.2 KiB
Markdown
# Diario de Desarrollo - service-monitor
|
|
|
|
## 2025-12-08 - Sesión 3: Migración Zig 0.15 + SMTP STARTTLS
|
|
|
|
### Contexto
|
|
- Migrar de Zig 0.13 a 0.15.2
|
|
- Implementar SMTP con STARTTLS para notificaciones por email
|
|
|
|
### Migración a Zig 0.15.2
|
|
|
|
**Cambios requeridos:**
|
|
|
|
| Componente | Antes (0.13) | Después (0.15) |
|
|
|------------|--------------|----------------|
|
|
| build.zig | `root_source_file` | `root_module` con `b.createModule()` |
|
|
| stdout | `std.io.getStdOut().writer()` | `std.fs.File.stdout().deprecatedWriter()` |
|
|
| ArrayList | `std.ArrayList(T).init(alloc)` | `std.array_list.Managed(T).init(alloc)` |
|
|
| file.reader() | sin args | requiere buffer, usar `deprecatedReader()` |
|
|
| HTTP Client | `client.open()` + `send()` + `wait()` | `client.fetch()` |
|
|
| sleep | `std.time.sleep()` | `std.Thread.sleep()` |
|
|
|
|
**Commits:**
|
|
- `f31ce95` - Migración a Zig 0.15.2
|
|
|
|
### SMTP con STARTTLS
|
|
|
|
**Problema inicial:**
|
|
Se intentó implementar TLS nativo con `std.crypto.tls.Client`, pero la nueva API de I/O
|
|
de Zig 0.15 resultó demasiado compleja (cambios en Reader/Writer interfaces).
|
|
|
|
**Solución adoptada:**
|
|
Usar curl como subprocess, igual que para Telegram. Ventajas:
|
|
- curl maneja STARTTLS con `--ssl-reqd` transparentemente
|
|
- Código mucho más simple y mantenible
|
|
- Fiable y probado
|
|
|
|
**Configuración SMTP (Mailbox.org):**
|
|
```
|
|
Host: smtp.mailbox.org
|
|
Puerto: 587 (STARTTLS)
|
|
Usuario: reugenio@mailbox.org
|
|
Password: App password (en NOTIFICACIONES.md)
|
|
```
|
|
|
|
**Commits:**
|
|
- `4a9d0e6` - SMTP con STARTTLS via curl
|
|
|
|
### Estado Final del Proyecto
|
|
|
|
**Todas las funcionalidades implementadas:**
|
|
- ✅ Verificación HTTP/HTTPS
|
|
- ✅ Verificación TCP
|
|
- ✅ Modo watch (loop continuo)
|
|
- ✅ Modo daemon (background)
|
|
- ✅ Log a archivo
|
|
- ✅ Config externo (CSV)
|
|
- ✅ Notificación desktop (notify-send)
|
|
- ✅ Notificación Telegram (Bot API via curl)
|
|
- ✅ Notificación Email (SMTP STARTTLS via curl)
|
|
|
|
**Estructura final:**
|
|
```
|
|
service-monitor/
|
|
├── build.zig
|
|
├── CLAUDE.md
|
|
├── services.conf
|
|
├── docs/
|
|
│ ├── DIARIO_DESARROLLO.md
|
|
│ └── PROYECTO_COMPLETO.md
|
|
└── src/
|
|
├── main.zig # Entry point + CLI
|
|
├── http.zig # Cliente HTTP (fetch API)
|
|
├── tcp.zig # Verificación TCP
|
|
├── config.zig # Parser CSV
|
|
├── notify.zig # notify-send
|
|
├── daemon.zig # fork + setsid
|
|
├── smtp.zig # SMTP via curl
|
|
└── telegram.zig # Bot API via curl
|
|
```
|
|
|
|
---
|
|
|
|
## 2025-12-07 - Sesión 2: Fases 2 y 3
|
|
|
|
### Implementado
|
|
- Modo watch con intervalo configurable
|
|
- Modo daemon con fork/setsid
|
|
- Log a archivo
|
|
- Config externo (services.conf)
|
|
- Notificaciones desktop (notify-send)
|
|
- Notificaciones Telegram (Bot API)
|
|
- SMTP básico (sin STARTTLS)
|
|
|
|
---
|
|
|
|
## 2025-12-07 - Sesión 1: Inicio proyecto
|
|
|
|
### Contexto
|
|
- Proyecto nuevo: Monitor de servicios para servidor Hetzner (Simba)
|
|
- Lenguaje: Zig 0.13.0
|
|
- Objetivo: Herramienta ligera, sin dependencias externas, potencialmente open source
|
|
|
|
### Implementado - Fase 1 Básica
|
|
|
|
**Estructura creada:**
|
|
```
|
|
service-monitor/
|
|
├── build.zig # Sistema build Zig
|
|
├── CLAUDE.md # Especificación proyecto
|
|
├── docs/ # Documentación
|
|
│ └── DIARIO_DESARROLLO.md
|
|
└── src/
|
|
├── main.zig # Entry point + output terminal
|
|
├── http.zig # Verificación HTTP/HTTPS (std.http.Client)
|
|
├── tcp.zig # Verificación TCP (std.net)
|
|
└── config.zig # Lista servicios hardcoded
|
|
```
|
|
|
|
**Servicios configurados:**
|
|
1. Forgejo HTTP - https://git.reugenio.com
|
|
2. Forgejo SSH - git.reugenio.com:2222
|
|
3. Simifactu API - https://simifactu.com
|
|
4. Mundisofa - https://mundisofa.com
|
|
5. Menzuri - https://menzuri.com
|
|
|
|
**Detalles técnicos Zig 0.13:**
|
|
- `std.http.Client.open()` requiere `server_header_buffer` obligatorio
|
|
- `std.time.Timer` debe ser `var` (no `const`) para llamar `.read()`
|
|
- Output con colores ANSI: `\x1b[32m` verde, `\x1b[31m` rojo, `\x1b[0m` reset
|
|
|
|
**Normas aplicadas:**
|
|
- Doc comments (`///`) en todas las funciones públicas
|
|
- Código idiomático Zig (snake_case, error handling explícito)
|
|
- Preparado para open source
|
|
|
|
### Comandos
|
|
```bash
|
|
zig build # Compilar
|
|
zig build run # Ejecutar verificación
|
|
```
|
|
|
|
---
|