fix: use separate db (same instance) for each node

This commit is contained in:
Arseniy Klempner 2025-10-11 22:51:58 -07:00
parent cc7ab12b42
commit d2699e3326
No known key found for this signature in database
GPG Key ID: 51653F18863BD24B
3 changed files with 12 additions and 2 deletions

View File

@ -27,6 +27,7 @@ services:
POSTGRES_DB: postgres
volumes:
- postgres-data:/var/lib/postgresql/data
- ./init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
@ -77,7 +78,7 @@ services:
- --rest-address=0.0.0.0
- --rest-port=8646
- --rest-admin=true
- --store-message-db-url=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-test123}@postgres:5432/postgres
- --store-message-db-url=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-test123}@postgres:5432/nwaku1
- --log-level=${LOG_LEVEL:-INFO}
- --max-connections=150
@ -126,7 +127,7 @@ services:
- --rest-address=0.0.0.0
- --rest-port=8647
- --rest-admin=true
- --store-message-db-url=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-test123}@postgres:5432/postgres
- --store-message-db-url=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-test123}@postgres:5432/nwaku2
- --log-level=${LOG_LEVEL:-INFO}
- --max-connections=150

8
packages/run/init-db.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
# Create separate databases for each nwaku node
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE DATABASE nwaku1;
CREATE DATABASE nwaku2;
EOSQL

View File

@ -27,6 +27,7 @@
"files": [
"dist",
"docker-compose.yml",
"init-db.sh",
"README.md"
],
"scripts": {