Skip to main content
Aegra provides three CLI commands for different deployment scenarios:
CommandStarts PostgreSQL?Starts app?Best for
aegra devYes (Docker)Yes (host, hot reload)Local development
aegra upYes (Docker)Yes (Docker)Self-hosted production
aegra serveNoYes (host)PaaS, containers, bare metal

Local development

aegra dev
This starts a PostgreSQL container via Docker Compose and runs the app on your host with hot reload. What it does:
  1. Finds or generates docker-compose.yml with PostgreSQL
  2. Starts the PostgreSQL container
  3. Loads your .env file
  4. Runs uvicorn with --reload for hot reloading
  5. Applies database migrations automatically on startup
OptionDefaultDescription
--host127.0.0.1Host to bind to
--port8000Port to bind to
--config / -cAuto-detectedPath to aegra.json
--env-file / -e.envPath to .env file
--file / -fAuto-detectedPath to docker-compose.yml
--no-db-checkSkip database readiness check

Self-hosted with Docker

aegra up
Starts the entire stack (PostgreSQL + app) in Docker containers. This is the recommended production deployment for your own infrastructure. What it does:
  1. Finds or generates docker-compose.yml with PostgreSQL + app service
  2. Builds the Docker image from your Dockerfile
  3. Starts all containers
  4. The app container runs aegra serve internally
  5. Migrations apply automatically on startup
The generated docker-compose.yml includes:
  • PostgreSQL with pgvector
  • Your app container built from Dockerfile
  • Health checks on PostgreSQL
  • Volume mounts for your graphs and config
To stop:
aegra down            # Stop containers
aegra down --volumes  # Stop and remove data volumes
OptionDefaultDescription
--build / --no-buildBuild onBuild images before starting
--file / -fAuto-detectedPath to compose file
SERVICE...AllSpecific services to start

PaaS deployment

For platforms like Railway, Render, or Fly.io — use aegra serve:
aegra serve
This runs uvicorn directly without starting PostgreSQL. You provide a running database via environment variables.
1

Create a PostgreSQL addon on your platform

Most PaaS platforms offer managed PostgreSQL. Create one and get the connection URL.
2

Set environment variables

DATABASE_URL=postgresql://user:password@host:5432/mydb
OPENAI_API_KEY=sk-...
AUTH_TYPE=noop  # or custom
3

Set the start command

aegra serve --host 0.0.0.0 --port $PORT
Or in your Dockerfile:
CMD ["aegra", "serve", "--host", "0.0.0.0", "--port", "8000"]
OptionDefaultDescription
--host0.0.0.0Host to bind to
--portFrom env or 8000Port to bind to
--config / -cAuto-detectedPath to aegra.json

Kubernetes

Use aegra serve as the container command in your pod spec:
containers:
  - name: aegra
    image: your-registry/your-agent:latest
    command: ["aegra", "serve", "--host", "0.0.0.0", "--port", "8000"]
    env:
      - name: DATABASE_URL
        valueFrom:
          secretKeyRef:
            name: aegra-secrets
            key: database-url
    ports:
      - containerPort: 8000
    readinessProbe:
      httpGet:
        path: /ready
        port: 8000
    livenessProbe:
      httpGet:
        path: /live
        port: 8000
PostgreSQL should be a managed service (CloudSQL, RDS, etc.) or a StatefulSet with persistent volumes.

Database configuration

Two ways to configure the database connection:
DATABASE_URL takes precedence. When set, individual POSTGRES_* variables are ignored.

Migrations

Migrations run automatically on startup for all deployment methods. You do not need to run them manually.

Health checks

Aegra provides health check endpoints for load balancers, Docker, and Kubernetes probes:
EndpointPurpose
GET /healthOverall health status
GET /readyReadiness check
GET /liveLiveness check
GET /infoServer info

Troubleshooting

PostgreSQL is not reachable. If using aegra dev or aegra up, make sure Docker is running. If using aegra serve, verify your DATABASE_URL or POSTGRES_* variables in .env.
Wrong database credentials. Check that POSTGRES_USER and POSTGRES_PASSWORD in your .env match what PostgreSQL was initialized with.
Migrations haven’t been applied. This usually means the server couldn’t connect to PostgreSQL during startup. Check the logs for connection errors, fix the connection, and restart.
Check if another process holds a lock on the database, if the database is reachable but slow, or check server logs for specific migration errors.