PostgreSQL
@elizaos/adapter-postgres
- Recommended for production deployments
- Scalable and robust
This guide covers deploying your Brain Framework agent on any long running Node.js server environment, including database setup considerations.
Currently some plugins donβt support serverless deployments. but we are planning to add support for serverless deployments in the future.
Choose the appropriate database adapter based on your deployment needs:
PostgreSQL
@elizaos/adapter-postgres
SQLite
@elizaos/adapter-sqlite
Supabase
@elizaos/adapter-supabase
Install required packages:
npm i github:elizaos-plugins/adapter-postgres
pnpm add github:elizaos-plugins/adapter-postgres
yarn add github:elizaos-plugins/adapter-postgres
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' } }] }
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();
Build and start:
pnpm build pm2 start ecosystem.config.js
# Required environment variablesDATABASE_URL=postgresql://user:pass@localhost:5432/db
# Set file locationDATABASE_PATH=./data/agent.db
# Required environment variablesSUPABASE_URL=your-project-urlSUPABASE_KEY=your-api-key