docs(path-b): cron entries for autosave + idle-sweep
Adds vibn-dev/CRON.md with copy-pasteable /etc/cron.d/vibn-path-b
template and smoke commands. Pairs with the
/api/admin/path-b/{autosave,idle-sweep} endpoints already shipped
in vibn-frontend.
Made-with: Cursor
This commit is contained in:
105
vibn-dev/CRON.md
Normal file
105
vibn-dev/CRON.md
Normal file
@@ -0,0 +1,105 @@
|
||||
# Path B cron entries
|
||||
|
||||
Two background jobs keep dev containers cheap and recoverable. Wire
|
||||
both to whatever scheduler is convenient (host crontab, Coolify
|
||||
Scheduled Tasks, or a separate vibn-cron service later).
|
||||
|
||||
## 1. Workspace autosave — every 5 min
|
||||
|
||||
Force-pushes `/workspace` of every running dev container to a
|
||||
`vibn-autosave/main` branch in the project's Gitea repo. Throttled
|
||||
internally so it's safe to call more often than 5 min if needed.
|
||||
|
||||
```cron
|
||||
*/5 * * * * curl -fsS -X POST \
|
||||
-H "Authorization: Bearer $NEXTAUTH_SECRET" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"sweep":true}' \
|
||||
https://vibnai.com/api/admin/path-b/autosave \
|
||||
>> /var/log/vibn-autosave.log 2>&1
|
||||
```
|
||||
|
||||
What it does on a per-project basis (see
|
||||
`autosaveWorkspace` in `vibn-frontend/lib/dev-container.ts`):
|
||||
|
||||
1. Skips containers that aren't `state='running'`.
|
||||
2. Skips containers without a `.git` directory in `/workspace`.
|
||||
3. `git checkout -B vibn-autosave/main`, adds everything, commits if
|
||||
there are changes, force-pushes.
|
||||
4. Records the push in `fs_dev_autosaves` (per-project history,
|
||||
bounded by retention you can prune later).
|
||||
|
||||
## 2. Idle-suspend sweep — every 5 min
|
||||
|
||||
Suspends every running dev container whose last `shell.exec` is older
|
||||
than 30 minutes. Coolify-stops the service; the workspace + cache
|
||||
volumes persist; resume happens automatically on the next
|
||||
`shell.exec` (~3-5s).
|
||||
|
||||
```cron
|
||||
*/5 * * * * curl -fsS -X POST \
|
||||
-H "Authorization: Bearer $NEXTAUTH_SECRET" \
|
||||
"https://vibnai.com/api/admin/path-b/idle-sweep?minutes=30" \
|
||||
>> /var/log/vibn-idle.log 2>&1
|
||||
```
|
||||
|
||||
Override the threshold per-tier later by passing a different
|
||||
`?minutes=` value. 30 was chosen because it covers a coffee break
|
||||
without disrupting active work.
|
||||
|
||||
## Quick install on the Coolify host
|
||||
|
||||
```bash
|
||||
sudo tee /etc/cron.d/vibn-path-b > /dev/null <<EOF
|
||||
NEXTAUTH_SECRET=<paste-from-.env.local-on-coolify>
|
||||
|
||||
# Workspace autosave to Gitea
|
||||
*/5 * * * * root curl -fsS -X POST \
|
||||
-H "Authorization: Bearer \$NEXTAUTH_SECRET" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"sweep":true}' \
|
||||
https://vibnai.com/api/admin/path-b/autosave \
|
||||
>> /var/log/vibn-autosave.log 2>&1
|
||||
|
||||
# Idle-suspend dev containers (30m threshold)
|
||||
*/5 * * * * root curl -fsS -X POST \
|
||||
-H "Authorization: Bearer \$NEXTAUTH_SECRET" \
|
||||
"https://vibnai.com/api/admin/path-b/idle-sweep?minutes=30" \
|
||||
>> /var/log/vibn-idle.log 2>&1
|
||||
EOF
|
||||
sudo chmod 0644 /etc/cron.d/vibn-path-b
|
||||
sudo systemctl reload cron
|
||||
```
|
||||
|
||||
## Manual smoke
|
||||
|
||||
```bash
|
||||
# autosave one project
|
||||
curl -X POST -H "Authorization: Bearer $NEXTAUTH_SECRET" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"projectId":"<vibn-project-id>"}' \
|
||||
https://vibnai.com/api/admin/path-b/autosave
|
||||
|
||||
# sweep all
|
||||
curl -X POST -H "Authorization: Bearer $NEXTAUTH_SECRET" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"sweep":true}' \
|
||||
https://vibnai.com/api/admin/path-b/autosave
|
||||
|
||||
# idle suspend (use a huge minutes value to dry-run safely)
|
||||
curl -X POST -H "Authorization: Bearer $NEXTAUTH_SECRET" \
|
||||
"https://vibnai.com/api/admin/path-b/idle-sweep?minutes=99999"
|
||||
```
|
||||
|
||||
## Disabling
|
||||
|
||||
If something goes wrong, flip the kill switch — the chat will fall
|
||||
back to gitea-write tools and the cron sweeps will return `scanned: 0`
|
||||
because no containers will be running.
|
||||
|
||||
```bash
|
||||
curl -X POST -H "Authorization: Bearer $NEXTAUTH_SECRET" \
|
||||
https://vibnai.com/api/admin/path-b/disable
|
||||
```
|
||||
|
||||
Re-enable later with `/api/admin/path-b/enable`.
|
||||
Reference in New Issue
Block a user