Skip to content

Deployment

This guide covers deploying your Brain Framework agent on any long running Node.js server environment, including database setup considerations.

Database Selection

Choose the appropriate database adapter based on your deployment needs:

PostgreSQL

@elizaos/adapter-postgres

  • Recommended for production deployments
  • Scalable and robust

SQLite

@elizaos/adapter-sqlite

  • Great for development and small deployments
  • Self-contained file database

Supabase

@elizaos/adapter-supabase

  • Cloud-native solution
  • Managed database service

Server Requirements

  • Node.js 18 or higher
  • pnpm 9.x (recommended)
  • Database system based on chosen adapter
  • Persistent storage for database files (if using SQLite)

Production Setup

  1. Install required packages:

    Terminal window
    npm i github:elizaos-plugins/adapter-postgres
  2. Create a PM2 ecosystem file (ecosystem.config.js):

    module.exports = {
    apps: [{
    name: 'brain-agent',
    script: './dist/index.js',
    instances: 1,
    autorestart: true,
    watch: false,
    max_memory_restart: '1G',
    env: {
    NODE_ENV: 'production',
    DATABASE_URL: 'postgresql://user:pass@localhost:5432/db'
    }
    }]
    }
  3. Configure your database adapter:

    import { AgentBuilder } from "@iqai/agent";
    import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres";
    const agent = new AgentBuilder()
    .withDatabase(new PostgresDatabaseAdapter({
    connectionString: process.env.DATABASE_URL
    }))
    .build();
  4. Build and start:

    Terminal window
    pnpm build
    pm2 start ecosystem.config.js

Database-Specific Considerations

Terminal window
# Required environment variables
DATABASE_URL=postgresql://user:pass@localhost:5432/db