Skip to content

chore(docs): add systemd service example, docker-compose, and troubleshooting (#49) - #65

Merged
savioruz merged 1 commit into
mainfrom
docs/systemd-service-and-troubleshooting
Aug 25, 2026
Merged

savioruz merged 1 commit into
mainfrom
docs/systemd-service-and-troubleshooting

Conversation

@savioruz

@savioruz savioruz commented Aug 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Docs-only PR that ships the self-hosted deployment + troubleshooting story for issue #49.

  • systemd unit (contrib/systemd/memayu.service): runs memayu serve as a persistent service — unprivileged memayu system user, Restart=on-failure, DB persisted at /var/lib/memayu/memayu.db via MEMAYU_LIBSQL_PATH, network-online.target ordering. Full setup snippet in the header comment.
  • docker-compose (contrib/docker-compose.yml): ghcr.io/savioruz/memayu:latest, restart: unless-stopped, memayu-data named volume, and a healthcheck that waits for /api/health to return "status":"ready" (container is healthy only after first-run setup). Includes the local-embedder recipe.
  • TROUBLESHOOTING.md (new): start with memayu doctor, then common config/storage/provider/env paths.
  • README: deploy/systemd + docker-compose pointers and the readiness contract.

No Rust/schema changes. CI build/clippy/test/audit are unaffected by docs; cargo fmt is green.

Checklist

Security

  • systemd unit runs as an unprivileged memayu user (not root); config.toml is chmod 600.
  • Compose healthcheck uses the unauthenticated /api/health readiness probe (no credentials in the probe).

…shooting (#49)

Ship deployment documentation for running memayu serve persistently:

- contrib/systemd/memayu.service: systemd unit example (restart on
  failure, unprivileged memayu user, config.toml based; no .env
  required). Documents config resolution order and setup steps.
- contrib/docker-compose.yml: compose example with a named data volume,
  restart: unless-stopped, and a /api/health readiness healthcheck.
- TROUBLESHOOTING.md: guides for config loading, /api/health states,
  provider 401/5xx/connection issues (real test calls), dimension
  mismatch, port in use, forgotten-password reset, API-key 401, and log
  locations.
- README.md: "Running as a service (systemd)" section with
  enable/start/status/logs commands, a Docker Compose pointer, and a
  link to TROUBLESHOOTING.md.
@savioruz savioruz assigned savioruz and unassigned savioruz Aug 25, 2026
@savioruz
savioruz marked this pull request as ready for review August 25, 2026 16:40
@savioruz savioruz added documentation Improvements or additions to documentation infra CI/release/distribution self-hosted Relates to self-hosted / local-first usage priority-medium Medium priority — important but not blocking labels Aug 25, 2026
@savioruz savioruz added this to the v0.1.0 milestone Aug 25, 2026
@savioruz

Copy link
Copy Markdown
Owner Author

Review of PR #65 at eb8d240596dc99a6bf998f17b749323099fbc47f (base main). Docs-only PR shipping self-hosted deployment + troubleshooting for issue #49.

🔴 Blocking

None. This is a documentation-only change (contrib/systemd/memayu.service, contrib/docker-compose.yml, TROUBLESHOOTING.md, README.md). No Rust code changes → CI build/clippy/test/audit are green-by-nature for docs; cargo fmt already pass; build/test pending is the repo-wide matrix (unaffected by docs).

🟡 Warning #1 — Dockerfile/compose healthcheck uses "ready" not setup_required, so a container reports "unhealthy" until setup completes

Per issue #47/#61, /api/health returns setup_required until the admin + provider config are in place. The compose healthcheck in this PR correctly waits for "status":"ready" (line ~"container transitions to healthy"). This is the right call, but it means docker compose ps (and k8s) will show unhealthy until first-run setup completes — worth a one-line callout in the troubleshooting section so operators don't mistake it for a crash. The compose file does call this out, but TROUBLESHOOTING.md should mirror it. Minor docs gap.

Validation

systemd unit (contrib/systemd/memayu.service) — issue #49

  • Type=simple, ExecStart=/usr/local/bin/memayu serve, Restart=on-failure, RestartSec=5, WantedBy=multi-user.target. After=network.target, Wants=network-online.target (start after network). ✅ persistent service.
  • Runs unprivileged: User=memayu/Group=memayu (system user, home /var/lib/memayu). WorkingDirectory=/var/lib/memayu.
  • Environment=MEMAYU_LIBSQL_PATH=/var/lib/memayu/memayu.db keeps the DB in the persisted workdir; the header comment explicitly notes this overrides config.toml's libsql_path (transparent). ✅
  • Setup steps documented (mkdir, useradd --system, chown, chmod 600 config). ✅ matches issue Document and ship a systemd unit file example for running memayu serve as a persistent service #49.

docker-compose (contrib/docker-compose.yml)

  • image: ghcr.io/savioruz/memayu:latest, restart: unless-stopped, 8080:8080, named volume memayu-data for DB persistence, and a healthcheck curling /api/health and grep-ing for "ready" with start-period. ✅ mirrors the Dockerfile + README Docker example.
  • Environment defaults documented (OpenAI-compatible); local-embedder recipe commented (MEMAYU_EMBEDDER_BACKEND: local, model, dim). ✅

TROUBLESHOOTING.md (new, 136 lines)

README update

  • Adds a "Deploy" / systemd + Docker-compose pointer referencing the new contrib/ artifacts and the health endpoint readiness contract. (Content read in full.)

Migration / breaking

  • Docs only; no code, no schema, no user-facing behavior change.

Checklist

Note: PR description was edited pre-review (issue ref #49, checklist, scope clarification). CI build/test/audit are pending in the matrix but are unaffected by docs-only changes (cargo fmt green); if the maintainer prefers CI fully green before review, that is fine — the substantive checks (systemd semantics, compose healthcheck, troubleshooting coverage) are source-based and satisfied. Comment updated in place per ZeroClaw convention.

@savioruz
savioruz merged commit 9fcfeda into main Aug 25, 2026
5 checks passed
@savioruz
savioruz deleted the docs/systemd-service-and-troubleshooting branch August 25, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation infra CI/release/distribution priority-medium Medium priority — important but not blocking self-hosted Relates to self-hosted / local-first usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant