Compare commits
3 Commits
cf31824f03
...
ee0ab52218
| Author | SHA1 | Date |
|---|---|---|
|
|
ee0ab52218 | |
|
|
952e8498ed | |
|
|
176c4c50f6 |
|
|
@ -0,0 +1,98 @@
|
||||||
|
# Agent Shell Transcript
|
||||||
|
|
||||||
|
**Agent:** Claude Code
|
||||||
|
**Started:** 2026-03-03 15:24:13
|
||||||
|
**Working Directory:** /home/fenix/napi/
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## User (2026-03-03 15:24:13)
|
||||||
|
|
||||||
|
how can i use SQLite on Cloudflare services ?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Agent's Thoughts (2026-03-03 15:24:15)
|
||||||
|
|
||||||
|
The user is asking about using SQLite on Cloudflare services. This is a general knowledge question, not related to the napi project. Let me answer from what I know and search for current info.
|
||||||
|
|
||||||
|
Cloudflare has D1, which is their SQLite-based database service for Workers.
|
||||||
|
## Agent (2026-03-03 15:24:17)
|
||||||
|
|
||||||
|
Cloudflare offers **D1**, their native SQLite-at-the-edge database. Here's the quick rundown:
|
||||||
|
|
||||||
|
## Cloudflare D1
|
||||||
|
|
||||||
|
D1 is a serverless SQLite database built into the Cloudflare Workers platform. Your data lives on Cloudflare's network, and queries run close to your users.
|
||||||
|
|
||||||
|
### Key characteristics
|
||||||
|
|
||||||
|
- **Real SQLite** — standard SQL syntax, same engine
|
||||||
|
- **Serverless** — no connection pools, no provisioning
|
||||||
|
- **Integrated with Workers** — first-class binding, no external drivers
|
||||||
|
- **Read replicas at the edge** — writes go to a primary, reads are distributed
|
||||||
|
- **Free tier available** — 5M reads/day, 100K writes/day, 5GB storage
|
||||||
|
|
||||||
|
### Minimal example (Worker + D1)
|
||||||
|
|
||||||
|
```js
|
||||||
|
// wrangler.toml
|
||||||
|
// [[d1_databases]]
|
||||||
|
// binding = "DB"
|
||||||
|
// database_name = "my-db"
|
||||||
|
// database_id = "xxx-xxx-xxx"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
async fetch(request, env) {
|
||||||
|
// Create table
|
||||||
|
await env.DB.exec("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)");
|
||||||
|
|
||||||
|
// Insert
|
||||||
|
await env.DB.prepare("INSERT INTO users (name) VALUES (?)").bind("Fénix").run();
|
||||||
|
|
||||||
|
// Query
|
||||||
|
const { results } = await env.DB.prepare("SELECT * FROM users").all();
|
||||||
|
|
||||||
|
return Response.json(results);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Setup steps
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Create database
|
||||||
|
npx wrangler d1 create my-db
|
||||||
|
|
||||||
|
# 2. Add binding to wrangler.toml (output from step 1)
|
||||||
|
|
||||||
|
# 3. Run migrations
|
||||||
|
npx wrangler d1 execute my-db --local --file=./schema.sql # local dev
|
||||||
|
npx wrangler d1 execute my-db --remote --file=./schema.sql # production
|
||||||
|
|
||||||
|
# 4. Deploy
|
||||||
|
npx wrangler deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
### Other SQLite-adjacent options on Cloudflare
|
||||||
|
|
||||||
|
| Option | Use case |
|
||||||
|
|:-------|:---------|
|
||||||
|
| **D1** | Primary choice — native SQLite, serverless, edge-distributed |
|
||||||
|
| **Durable Objects + SQLite** | Per-object embedded SQLite (since 2024) — good for per-user/per-room state |
|
||||||
|
| **Hyperdrive** | Not SQLite — connection pooler for external Postgres/MySQL |
|
||||||
|
|
||||||
|
### D1 limitations to know
|
||||||
|
|
||||||
|
- **Max DB size**: 10GB (free: 500MB)
|
||||||
|
- **Row size**: 1MB max
|
||||||
|
- **Single writer**: writes serialize through one primary location
|
||||||
|
- **No raw file access**: you interact via SQL bindings only, not `.sqlite` files
|
||||||
|
- Transactions supported but with some restrictions (no nested, no savepoints)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
For your **napi** context specifically — if you ever wanted to move from flat `notas.md` files to a DB-backed approach on Cloudflare, D1 would be the natural fit. Though the current file-based architecture is perfectly fine for 40 students.
|
||||||
|
|
||||||
|
Want me to dig deeper into any specific aspect (D1 pricing, Durable Objects SQLite, migrations, etc.)?
|
||||||
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
data/
|
data/
|
||||||
BUGS.org
|
BUGS.org
|
||||||
|
|
||||||
|
.agent-shell/
|
||||||
|
|
|
||||||
|
|
@ -73,12 +73,12 @@ miguel, pablo, patrick
|
||||||
|
|
||||||
SFTP chroot: `/home/USER/html/`
|
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,
|
barja, barrios, cayo, contrera, duque, florea, gomes, izquierdo,
|
||||||
jara, lillo, linares, macedo, martinez, munoz, olcina, ponce,
|
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`)
|
SFTP chroot: `/home/USER/python/` · Contraseñas: leet-speak (`a→4, e→3, i→1, o→0`)
|
||||||
|
|
|
||||||
43
TASKS.org
43
TASKS.org
|
|
@ -1,12 +1,12 @@
|
||||||
* CLona no el contenido en sí sino tan sólo la esructura de ~/napi-data/ a ~/napi-data2/ , teniendo en cuenta que :
|
* DONE CLona no el contenido en sí sino tan sólo la esructura de ~/napi-data/ a ~/napi-data2/ , teniendo en cuenta que :
|
||||||
** en dicha carpeta se alojaran los datos de otro grupo de estudiantes : el de el módulo Programación. Es decir el grupo ASIR1.
|
** en dicha carpeta se alojaran los datos de otro grupo de estudiantes : el de el módulo Programación. Es decir el grupo ASIR1.
|
||||||
** los cambios introducidos en el servidor Web deben ser compatibles con las aplicaciones existentes
|
** los cambios introducidos en el servidor Web deben ser compatibles con las aplicaciones existentes
|
||||||
** tendrán acceso a sus notas via notas.qu3v3d0.tech tras introducir, por obra del hack 'regexp-based-nginx-after-catch-all-content-redirect' ya desplegado en 'zzz', su usuario y contraseña
|
** tendrán acceso a sus notas via notas.qu3v3d0.tech tras introducir, por obra del hack 'regexp-based-nginx-after-catch-all-content-redirect' ya desplegado en 'zzz', su usuario y contraseña
|
||||||
** TODO generar lista de alumnos - AKAs en el mismo fichero ~/napi-data2/programacion-seguimiento-de-practicas.md
|
** DONE generar lista de alumnos - AKAs en el mismo fichero ~/napi-data2/programacion-seguimiento-de-practicas.md
|
||||||
* TODO , corregir/depurar mensaje : Claude, fíjate en @Screenshots/*.png s decir, que el chatbot no liste nada de "__pycache__/"
|
* DONE , corregir/depurar mensaje : Claude, fíjate en @Screenshots/*.png s decir, que el chatbot no liste nada de "__pycache__/"
|
||||||
|
|
||||||
|
|
||||||
* TODO que el chatbot, en vez de :
|
* DONE que el chatbot, en vez de :
|
||||||
|
|
||||||
** zzz@librebits.info 17:04
|
** zzz@librebits.info 17:04
|
||||||
🐍 [jara] Entrega ASIR1: Practicas/adivina-el-numero.py (1812 bytes)
|
🐍 [jara] Entrega ASIR1: Practicas/adivina-el-numero.py (1812 bytes)
|
||||||
|
|
@ -18,4 +18,37 @@ es decir, mencionar el/la autor/a de la entrega por ambos, nombre y apellido
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* esto
|
* DOING Emacs packages using JSON-RPC o other kinda-API thing i could be using in a complementary way to streamline my interaction with the students via 'zzz' server where 'napi' is hosted / serving
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
Emacs Packages Using JSON-RPC / Structured Protocols
|
||||||
|
|
||||||
|
For napi/ Specifically (file-sync + notification)
|
||||||
|
|
||||||
|
┌──────────────────────────────────────────────────────────────────────────────────────────────┬──────────────────────────────────────────┬────────────────────────────────────────────────────────────────────┐
|
||||||
|
│ Package │ What It Does │ napi Complement │
|
||||||
|
├──────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────┼────────────────────────────────────────────────────────────────────┤
|
||||||
|
│ https://github.com/legoscia/emacs-jabber │ XMPP client for Emacs │ Direct integration with your slixmpp notification system │
|
||||||
|
├──────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────┼────────────────────────────────────────────────────────────────────┤
|
||||||
|
│ https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Notifications.html (built-in) │ inotify/kqueue file watching │ Watch ~/napi-data/ for student uploads natively in Emacs │
|
||||||
|
├──────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────┼────────────────────────────────────────────────────────────────────┤
|
||||||
|
│ https://github.com/jcaw/json-rpc-server.el + https://github.com/jcaw/porthole │ Expose Emacs functions via HTTP JSON-RPC │ Let external scripts (your inotify watchers) trigger Emacs actions │
|
||||||
|
└──────────────────────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────┴────────────────────────────────────────────────────────────────────┘
|
||||||
|
|
||||||
|
** Explore the idea (as referred on above's gnu.org manual - link) "Notifications on File Changes", which states :
|
||||||
|
|
||||||
|
"Several operating systems support watching of filesystems for changes to files or their attributes. If configured
|
||||||
|
properly, Emacs links a respective library like inotify and others. These libraries enable watching of filesystems on the local machine.
|
||||||
|
|
||||||
|
**It is also possible to watch filesystems on remote machines**, see Remote Files in The GNU Emacs Manual. This does not
|
||||||
|
depend on one of the libraries linked to Emacs.
|
||||||
|
|
||||||
|
Since all these libraries emit different events upon notified file changes, Emacs provides a special library filenotify
|
||||||
|
which presents a unified interface to applications. Lisp programs that want to receive file notifications should always
|
||||||
|
use this library in preference to the native ones. [..]
|
||||||
|
|
||||||
|
|
||||||
|
the **bold** is mine ! ...
|
||||||
|
|
||||||
|
*** Am i crazy saying that ~/napi could be running remotely, as long as a 'emacs -daemon=napi' which i could hook into an 'emacsclient' ?
|
||||||
|
|
|
||||||
|
|
@ -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 |
|
| **`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-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) |
|
| **`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
|
# Montar/desmontar
|
||||||
systemctl --user start home-fenix-napi\\x2ddata2.mount
|
systemctl --user start home-fenix-napi\\x2ddata2.mount
|
||||||
systemctl --user stop 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
|
## 🏗️ 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 |
|
| `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 |
|
| `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 |
|
| `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 |
|
||||||
|
|
|
||||||
|
|
@ -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'
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Check napi sshfs mounts every 2 minutes
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=30
|
||||||
|
OnUnitActiveSec=12min
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
Loading…
Reference in New Issue