Overview
Combined server: HTTP API + dashboard + background daemon loop in one process. This is the Docker container entrypoint, but can also be run directly for development without Docker.Syntax
Parameters
Bind address for the HTTP server. Use
0.0.0.0 to listen on all interfaces or 127.0.0.1 for localhost only.Bind port for the HTTP server. Can also be configured via
server_port in config.Examples
Start with defaults
Start the server on all interfaces, port 8765:Custom host and port
Run on localhost only with a custom port:What runs
When you runlerim serve, three components start in one process:
1. HTTP API server
Exposes endpoints for client commands:POST /api/sync- Sync sessions and extract memoriesPOST /api/maintain- Run memory refinementPOST /api/ask- Answer questions using memoryGET /api/status- Get runtime status
2. Dashboard web UI
Served at the root path (http://localhost:8765/):
- Overview metrics and charts
- Session browser and viewer
- Memory library and editor
- Pipeline status and queue
- Settings editor
3. Background daemon
Runs periodic sync and maintain cycles:- Sync: Every 10 minutes (default) - index new sessions and extract memories
- Maintain: Every 60 minutes (default) - refine existing memories
Sync and maintain intervals are independent and configurable via
sync_interval_minutes and maintain_interval_minutes in config.Configuration
The server reads from layered config (low to high priority):src/lerim/config/default.toml(package defaults)~/.lerim/config.toml(user global)<repo>/.lerim/config.toml(project overrides)LERIM_CONFIGenv var (explicit override)
Daemon behavior
The background daemon runs two independent loops:Sync loop
- Wait
sync_interval_minutes(default 10) - Discover new sessions from connected platforms (within
sync_window_dayswindow) - Enqueue up to
sync_max_sessionsfor extraction - Extract memories using DSPy
- Write decisions and learnings to
.lerim/memory/ - Repeat
Maintain loop
- Wait
maintain_interval_minutes(default 60) - Scan existing memories
- Merge duplicates
- Archive low-value items
- Consolidate related memories
- Apply time-based decay
- Repeat
Signal handling
Graceful shutdown onSIGTERM or SIGINT (Ctrl+C):
- Sets a stop event
- Waits for the current daemon cycle to complete
- Closes the HTTP server
- Exits cleanly
Use cases
Docker entrypoint
Thelerim up command generates a docker-compose.yml that runs lerim serve as the container entrypoint:
Development without Docker
Run Lerim directly on your host:- Local development and debugging
- Testing config changes
- Running on systems without Docker
Custom server setup
Bind to localhost only for secure access:Exit codes
- 0: Success - server stopped gracefully
- 1: Error - startup failure (port in use, config error, etc.)
Related commands
lerim up
Start Lerim in Docker
lerim daemon
Run daemon loop only (no HTTP server)
Troubleshooting
Port already in use
No connected platforms
If no platforms are connected, sync will find no sessions:API key errors
If extraction fails with auth errors, set your API keys:Notes
- The HTTP server uses
ThreadingHTTPServerfor concurrent request handling - The daemon thread is marked
daemon=Trueso it won’t block process exit - Daemon errors are logged but don’t crash the server
- The server initializes the sessions database on startup