(Startup, health checks, shutdown, and common operations)
This runbook covers:
- Startup procedures (local development and production)
- Health checks and verification
- Shutdown and cleanup
- Common operations (migrations, backups)
- Emergency procedures and troubleshooting pointers
It does not cover:
- Feature-level behavior (see subsystem docs)
- Deployment pipeline (see Deployment)
- Detailed troubleshooting (see Troubleshooting)
- Prerequisites: Node.js v18/v20, npm 9+.
- Environment: Copy or create
.env(see Getting started). For local storage, no env vars are required (defaults: local backend,./data,./data/neotoma.db,./data/sources). - Install and migrate:
npm install npm run migrate
- Start services:
- MCP server (stdio):
npm run dev - API only (MCP at /mcp):
npm run dev:server - Full stack (API + UI):
npm run dev:full - WebSocket MCP bridge:
npm run dev:ws
- MCP server (stdio):
- Verify: Run
npm run doctor(see Health check).
- Build:
npm run build:server. - Set production env (data paths, HTTPS, OAuth config).
- Run migrations:
npm run migrateor ensure local DB path is correct. - Start:
node dist/actions.js(API) ornode dist/index.js(stdio MCP). Use a process manager (e.g. systemd, PM2) and HTTPS in front. - Verify health:
npm run doctorand smoke-test critical endpoints.
For a headless systemd-supervised deployment of the npm-installed CLI
(including a reference unit file, lockdown flags, and smoke-test commands),
see install.md § Production deployment (headless / systemd).
Two distinct tools share the word "doctor":
npm run doctor(the dev/ops health-check script,scripts/doctor.ts— environment, database, RLS, storage, migrations, security) andneotoma status(the CLI command formerly namedneotoma doctor— CLI path, data directory, local API, MCP entries, permissions). This runbook usesnpm run doctorfor operator health checks andneotoma status --jsononly where CLI/data-dir state is needed.
- Primary: Run
npm run doctorfor environment, database, RLS, storage, migrations, and security checks. See Health check. - Manual: Run tests (
npm test,npm run test:integration), type-check (npm run type-check), and lint (npm run lint). - Runtime: Hit API health/readiness endpoints if configured; confirm MCP server starts (e.g. stdio mode).
- Graceful: Stop the Node process (SIGTERM). Allow in-flight requests to complete; process managers typically send SIGTERM then SIGKILL after a timeout.
- Cleanup: No mandatory cleanup for normal shutdown. For local dev, ensure no stray
tsx watchor dev servers if switching branches (ports may be in use).
- Migrations: Apply with
npm run migrate. Dry-run:npm run migrate:dry-run. See Troubleshooting for "relation does not exist" and RLS issues. - Backups: For local SQLite, copy the DB (default
./data/neotoma.dbin dev,./data/neotoma.prod.dbin prod, underNEOTOMA_DATA_DIR),NEOTOMA_RAW_STORAGE_DIR(default./data/sourcesin dev,./data/sources_prodin prod), andNEOTOMA_LOGS_DIR(default./data/logsin dev,./data/logs_prodin prod; includesevents.log). - User and access: Auth and user management are in Auth.
mainmust require the GitHub Actions checksecurity_gates.- Keep this rule enabled even if
/releaseis run manually; the required check is the PR-time guard against manifest drift, auth-matrix regressions, and security-lint failures.
- Rollback: Revert deployment to previous version; re-run migrations only if a migration rollback is defined (see migration docs). Restore DB/storage from backup if data corruption is suspected.
- SQLite corruption: If Neotoma reports
database disk image is malformed,btreeInitPage, or a failedPRAGMA integrity_check, runneotoma storage recover-dbfirst. If it reports corruption, stop Neotoma and runneotoma storage recover-db --recoverto write a recovered copy. Review and swap files manually; do not auto-replace the live DB. If corruption recurs on macOS, moveNEOTOMA_DATA_DIRout of iCloud-syncedDocuments,Desktop, oriCloud Drivefolders withneotoma storage set-data-dir "~/Library/Application Support/neotoma/data" --move-db-files, then rerunneotoma status --jsonand confirmdata.risksis empty. - Incident response: Triage using Troubleshooting. Check logs and
npm run doctoroutput. For security issues, see SECURITY.md in the source root.
| Symptom | See |
|---|---|
| Missing env / connection errors | Troubleshooting – Setup |
| Database / RLS errors | Troubleshooting – Runtime |
| Port in use | Troubleshooting – Port |
| Health check failures | Health check |