feat: add sshfs mount watchdog timer for auto-recovery

When zzz reboots or SSH drops, mounts stay in failed state forever.
New watchdog timer checks every 12min and restarts any failed mount.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
fenix 2026-03-10 14:02:54 +01:00
parent 952e8498ed
commit ee0ab52218
4 changed files with 38 additions and 2 deletions

View File

@ -73,12 +73,12 @@ miguel, pablo, patrick
SFTP chroot: `/home/USER/html/`
### ASIR1 (21) — usernames = apellido en minúsculas
### ASIR1 (22) — usernames = apellido en minúsculas
```
barja, barrios, cayo, contrera, duque, florea, gomes, izquierdo,
jara, lillo, linares, macedo, martinez, munoz, olcina, ponce,
posada, quiroz, reynoso, sierra, torrero
posada, quiroz, reynoso, rodriguez, sierra, torrero
```
SFTP chroot: `/home/USER/python/` · Contraseñas: leet-speak (`a→4, e→3, i→1, o→0`)

View File

@ -15,6 +15,8 @@ Copia de referencia de todos los scripts y unidades systemd desplegados en **zzz
| **`nginx-user-config-watcher.service`** | `zzz:/etc/systemd/system/` | Unit systemd para el watcher DDAW2 |
| **`home-fenix-napi-data.mount`** | `aldebaran:~/.config/systemd/user/` | Mount sshfs `~/napi-data/``zzz:/var/www/napi/data/` (DDAW2) |
| **`home-fenix-napi-data2.mount`** | `aldebaran:~/.config/systemd/user/` | Mount sshfs `~/napi-data2/``zzz:/var/www/napi2/data/` (ASIR1) |
| **`napi-mount-watchdog.service`** | `aldebaran:~/.config/systemd/user/` | Watchdog — reinicia mounts sshfs caídos |
| **`napi-mount-watchdog.timer`** | `aldebaran:~/.config/systemd/user/` | Timer — ejecuta watchdog cada 12 min |
---
@ -125,8 +127,20 @@ systemctl --user status home-fenix-napi\\x2ddata2.mount # ASIR1
# Montar/desmontar
systemctl --user start home-fenix-napi\\x2ddata2.mount
systemctl --user stop home-fenix-napi\\x2ddata2.mount
# Watchdog (auto-recovery de mounts caídos)
systemctl --user status napi-mount-watchdog.timer
systemctl --user list-timers napi-mount-watchdog.timer
```
### 🐕 napi-mount-watchdog (timer + service)
**Propósito:** Auto-recuperación de mounts sshfs caídos. Si zzz se reinicia o la conexión SSH se corta, el watchdog detecta los mounts en estado `failed` y los reinicia automáticamente.
- ⏱️ **Frecuencia:** cada 12 minutos (+ 30s tras boot)
- 🔍 **Lógica:** comprueba `is-active` de ambos `.mount` → reinicia los que no estén `active`
- 🛡️ **Complementa** el `reconnect` de sshfs (que solo maneja blips breves, no fallos de mount inicial)
---
## 🏗️ Estructura de directorios en zzz
@ -166,3 +180,4 @@ systemctl --user stop home-fenix-napi\\x2ddata2.mount
| `python-upload-watcher.sh` | **v7** | 2026-02-25 | Batching + re-entregas + Windows-safe + `__pycache__` filter + nombres completos |
| `nginx-user-config-watcher.sh` | **v3** | 2026-02-19 | Multi-sitio + undeploy + CSP analysis |
| `xmpp-notify.py` | **v1** | 2026-01-27 | Bot one-shot slixmpp |
| `napi-mount-watchdog` | **v1** | 2026-03-10 | Timer+service watchdog para auto-recovery de mounts sshfs |

View File

@ -0,0 +1,12 @@
[Unit]
Description=Restart failed napi sshfs mounts
[Service]
Type=oneshot
ExecStart=/bin/bash -c '\
for unit in home-fenix-napi\\x2ddata.mount home-fenix-napi\\x2ddata2.mount; do \
state=$(systemctl --user is-active "$unit" 2>/dev/null); \
if [ "$state" != "active" ]; then \
systemctl --user restart "$unit"; \
fi; \
done'

View File

@ -0,0 +1,9 @@
[Unit]
Description=Check napi sshfs mounts every 2 minutes
[Timer]
OnBootSec=30
OnUnitActiveSec=12min
[Install]
WantedBy=timers.target