From 159c21c7dd145dac6fdabf0663d37de28a55d22d Mon Sep 17 00:00:00 2001 From: stubbsta Date: Tue, 3 Dec 2024 09:15:46 +0200 Subject: [PATCH] WIP --- docker-compose.yml | 406 +++++++++++++++++-------------- monitoring/prometheus-config.yml | 2 + run_nwaku_store_postgres1.sh | 7 +- run_nwaku_store_postgres2.sh | 7 +- run_nwaku_store_postgres3.sh | 46 ++++ run_nwaku_store_postgres4.sh | 46 ++++ 6 files changed, 324 insertions(+), 190 deletions(-) create mode 100644 run_nwaku_store_postgres3.sh create mode 100644 run_nwaku_store_postgres4.sh diff --git a/docker-compose.yml b/docker-compose.yml index 747345f..d97d343 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,45 +12,45 @@ services: # Accounts are hardcoded to 520 with the idea that nwaku nodes use up to 500 for membership registration and the last 20 are used for ad-hoc testing. # The account number and private key pairs of the last 20 accounts can be found in the Register memberships section of the Waku-simulator book. - # foundry: - # image: ghcr.io/foundry-rs/foundry:nightly-9b73e06e1fe376738b92ae081107620291d50188 - # labels: - # com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' - # ports: - # - 0.0.0.0:8545:8545 - # command: - # - anvil - # --port=8545 - # --host=0.0.0.0 - # --accounts=520 - # --allow-origin=* - # --block-time=3 - # --chain-id=1234 - # --silent - # --config-out=/shared/anvil-config.txt - # volumes: - # - privatekeys-volume:/shared - # networks: - # - simulation + foundry: + image: ghcr.io/foundry-rs/foundry:nightly-9b73e06e1fe376738b92ae081107620291d50188 + labels: + com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' + ports: + - 0.0.0.0:8545:8545 + command: + - anvil + --port=8545 + --host=0.0.0.0 + --accounts=520 + --allow-origin=* + --block-time=3 + --chain-id=1234 + --silent + --config-out=/shared/anvil-config.txt + volumes: + - privatekeys-volume:/shared + networks: + - simulation - # contract-repo-deployer: - # image: node:hydrogen-bullseye - # labels: - # com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' - # environment: - # - PRIVATE_KEY=${PRIVATE_KEY} - # - RPC_URL=${RPC_URL:-http://foundry:8545} - # - ETH_FROM=${ETH_FROM} - # - MAX_MESSAGE_LIMIT=${MAX_MESSAGE_LIMIT:-20} - # entrypoint: sh - # command: - # - '/opt/deploy_rln_contract.sh' - # volumes: - # - ./deploy_rln_contract.sh:/opt/deploy_rln_contract.sh - # depends_on: - # - foundry - # networks: - # - simulation + contract-repo-deployer: + image: node:hydrogen-bullseye + labels: + com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' + environment: + - PRIVATE_KEY=${PRIVATE_KEY} + - RPC_URL=${RPC_URL:-http://foundry:8545} + - ETH_FROM=${ETH_FROM} + - MAX_MESSAGE_LIMIT=${MAX_MESSAGE_LIMIT:-20} + entrypoint: sh + command: + - '/opt/deploy_rln_contract.sh' + volumes: + - ./deploy_rln_contract.sh:/opt/deploy_rln_contract.sh + depends_on: + - foundry + networks: + - simulation bootstrap: image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} @@ -80,77 +80,72 @@ services: replicas: ${NUM_NWAKU_NODES:-5} entrypoint: sh command: - - '/opt/run_nwaku_noRLN.sh' + - '/opt/run_nwaku.sh' volumes: - - ./run_nwaku_noRLN.sh:/opt/run_nwaku_noRLN.sh:Z + - ./run_nwaku_noRLN.sh:/opt/run_nwaku.sh:Z depends_on: - bootstrap networks: - simulation - nwaku_store_pg1: - image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} - restart: on-failure - labels: - com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' - # ports: - # - 127.0.0.1:60001:60001 - entrypoint: sh - environment: - - POSTGRES_USER=${POSTGRES_USER:-postgres} - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} - - WAKU_SYNC_INTERVAL=${WAKU_SYNC_INTERVAL:-300} - - WAKU_SYNC_RANGE=${WAKU_SYNC_RANGE:-3600} - command: - - '/opt/run_nwaku_store_postgres1.sh' - volumes: - - ./run_nwaku_store_postgres1.sh:/opt/run_nwaku_store_postgres1.sh:Z - depends_on: - postgres1: - condition: service_healthy - networks: - simulation: - ipv4_address: 10.2.0.100 + # nwaku_store_pg1: + # image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} + # restart: on-failure + # labels: + # com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' + # entrypoint: sh + # environment: + # - POSTGRES_USER=${POSTGRES_USER:-postgres} + # - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} + # - WAKU_SYNC_INTERVAL=${WAKU_SYNC_INTERVAL:-300} + # - WAKU_SYNC_RANGE=${WAKU_SYNC_RANGE:-3600} + # command: + # - '/opt/run_nwaku_store_postgres1.sh' + # volumes: + # - ./run_nwaku_store_postgres1.sh:/opt/run_nwaku_store_postgres1.sh:Z + # depends_on: + # postgres1: + # condition: service_healthy + # networks: + # simulation: + # ipv4_address: 10.2.0.100 + - nwaku_store_pg2: - image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} - restart: on-failure - labels: - com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' - # ports: - # - 127.0.0.1:60002:60002 - entrypoint: sh - environment: - - POSTGRES_USER=${POSTGRES_USER:-postgres} - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} - - WAKU_SYNC_INTERVAL=${WAKU_SYNC_INTERVAL:-300} - - WAKU_SYNC_RANGE=${WAKU_SYNC_RANGE:-3600} - command: - - '/opt/run_nwaku_store_postgres2.sh' - volumes: - - ./run_nwaku_store_postgres2.sh:/opt/run_nwaku_store_postgres2.sh:Z - depends_on: - nwaku_store_pg1: - condition: service_started - postgres2: - condition: service_healthy - networks: - simulation: - ipv4_address: 10.2.0.101 + # nwaku_store_pg2: + # image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} + # restart: on-failure + # labels: + # com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' + # entrypoint: sh + # environment: + # - POSTGRES_USER=${POSTGRES_USER:-postgres} + # - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} + # - WAKU_SYNC_INTERVAL=${WAKU_SYNC_INTERVAL:-300} + # - WAKU_SYNC_RANGE=${WAKU_SYNC_RANGE:-3600} + # command: ["-c", "sleep 30 && /opt/run_nwaku_store_postgres2.sh"] + # volumes: + # - ./run_nwaku_store_postgres2.sh:/opt/run_nwaku_store_postgres2.sh:Z + # depends_on: + # nwaku_store_pg1: + # condition: service_started + # postgres2: + # condition: service_healthy + # networks: + # simulation: + # ipv4_address: 10.2.0.101 # nwaku_store_pg3: # image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} # restart: on-failure # labels: # com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' - # ports: - # - 127.0.0.1:60003:60003 # entrypoint: sh # environment: # - POSTGRES_USER=${POSTGRES_USER:-postgres} # - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} - # command: - # - '/opt/run_nwaku_store_postgres3.sh' + # - WAKU_SYNC_INTERVAL=${WAKU_SYNC_INTERVAL:-300} + # - WAKU_SYNC_RANGE=${WAKU_SYNC_RANGE:-3600} + # command: ["-c", "sleep 60 && /opt/run_nwaku_store_postgres3.sh"] # volumes: # - ./run_nwaku_store_postgres3.sh:/opt/run_nwaku_store_postgres3.sh:Z # depends_on: @@ -161,6 +156,29 @@ services: # networks: # simulation: # ipv4_address: 10.2.0.102 + + # nwaku_store_pg4: + # image: ${NWAKU_IMAGE:-wakuorg/nwaku:latest} + # restart: on-failure + # labels: + # com.centurylinklabs.watchtower.enable: '${WATCHTOWER_ENABLED:-false}' + # entrypoint: sh + # environment: + # - POSTGRES_USER=${POSTGRES_USER:-postgres} + # - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} + # - WAKU_SYNC_INTERVAL=${WAKU_SYNC_INTERVAL:-300} + # - WAKU_SYNC_RANGE=${WAKU_SYNC_RANGE:-3600} + # command: ["-c", "sleep 85 && /opt/run_nwaku_store_postgres4.sh"] + # volumes: + # - ./run_nwaku_store_postgres4.sh:/opt/run_nwaku_store_postgres4.sh:Z + # depends_on: + # nwaku_store_pg1: + # condition: service_started + # postgres4: + # condition: service_healthy + # networks: + # simulation: + # ipv4_address: 10.2.0.103 # rest-traffic: # image: alrevuelta/rest-traffic:6992bb5 @@ -175,99 +193,123 @@ services: # depends_on: # - nwaku - postgres1: - # This service is used when the Waku node has the 'store' protocol enabled - # and the store-message-db-url is set to use Postgres - image: postgres:15.4-alpine3.18 - restart: on-failure:5 - environment: - - POSTGRES_USER=${POSTGRES_USER:-postgres} - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} - volumes: - - ./postgres_cfg/postgresql.conf:/etc/postgresql/postgresql.conf:Z - - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z - - ${PG_DATA_DIR:-./postgresql1}:/var/lib/postgresql/data:Z - command: postgres -c config_file=/etc/postgresql/postgresql.conf - ports: - - 0.0.0.0:5432:5432 - networks: - - simulation - healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"] - interval: 30s - timeout: 60s - retries: 5 - start_period: 80s + # postgres1: + # # This service is used when the Waku node has the 'store' protocol enabled + # # and the store-message-db-url is set to use Postgres + # image: postgres:15.4-alpine3.18 + # restart: on-failure:5 + # environment: + # - POSTGRES_USER=${POSTGRES_USER:-postgres} + # - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} + # volumes: + # - ./postgres_cfg/postgresql.conf:/etc/postgresql/postgresql.conf:Z + # - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z + # - ${PG_DATA_DIR:-./postgresql1}:/var/lib/postgresql/data:Z + # command: postgres -c config_file=/etc/postgresql/postgresql.conf + # ports: + # - 0.0.0.0:5432:5432 + # networks: + # - simulation + # healthcheck: + # test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"] + # interval: 30s + # timeout: 60s + # retries: 5 + # start_period: 80s - postgres2: - # This service is used when the Waku node has the 'store' protocol enabled - # and the store-message-db-url is set to use Postgres - image: postgres:15.4-alpine3.18 - restart: on-failure:5 - environment: - - POSTGRES_USER=${POSTGRES_USER:-postgres} - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} - volumes: - - ./postgres_cfg/postgresql.conf:/etc/postgresql/postgresql.conf:Z - - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z - - ${PG_DATA_DIR:-./postgresql2}:/var/lib/postgresql/data:Z - command: postgres -c config_file=/etc/postgresql/postgresql.conf - ports: - - 0.0.0.0:5433:5432 - networks: - - simulation - healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"] - interval: 30s - timeout: 60s - retries: 5 - start_period: 80s + # postgres2: + # # This service is used when the Waku node has the 'store' protocol enabled + # # and the store-message-db-url is set to use Postgres + # image: postgres:15.4-alpine3.18 + # restart: on-failure:5 + # environment: + # - POSTGRES_USER=${POSTGRES_USER:-postgres} + # - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} + # volumes: + # - ./postgres_cfg/postgresql.conf:/etc/postgresql/postgresql.conf:Z + # - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z + # - ${PG_DATA_DIR:-./postgresql2}:/var/lib/postgresql/data:Z + # command: postgres -c config_file=/etc/postgresql/postgresql.conf + # ports: + # - 0.0.0.0:5433:5432 + # networks: + # - simulation + # healthcheck: + # test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"] + # interval: 30s + # timeout: 60s + # retries: 5 + # start_period: 80s - postgres3: - # This service is used when the Waku node has the 'store' protocol enabled - # and the store-message-db-url is set to use Postgres - image: postgres:15.4-alpine3.18 - restart: on-failure:5 - environment: - - POSTGRES_USER=${POSTGRES_USER:-postgres} - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} - volumes: - - ./postgres_cfg/postgresql.conf:/etc/postgresql/postgresql.conf:Z - - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z - - ${PG_DATA_DIR:-./postgresql3}:/var/lib/postgresql/data:Z - command: postgres -c config_file=/etc/postgresql/postgresql.conf - ports: - - 0.0.0.0:5434:5432 - networks: - - simulation - healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"] - interval: 30s - timeout: 60s - retries: 5 - start_period: 80s + # postgres3: + # # This service is used when the Waku node has the 'store' protocol enabled + # # and the store-message-db-url is set to use Postgres + # image: postgres:15.4-alpine3.18 + # restart: on-failure:5 + # environment: + # - POSTGRES_USER=${POSTGRES_USER:-postgres} + # - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} + # volumes: + # - ./postgres_cfg/postgresql.conf:/etc/postgresql/postgresql.conf:Z + # - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z + # - ${PG_DATA_DIR:-./postgresql3}:/var/lib/postgresql/data:Z + # command: postgres -c config_file=/etc/postgresql/postgresql.conf + # ports: + # - 0.0.0.0:5434:5432 + # networks: + # - simulation + # healthcheck: + # test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"] + # interval: 30s + # timeout: 60s + # retries: 5 + # start_period: 100s - postgres-exporter: - # Service aimed to scrape information from Postgres and post it to Prometeus - image: quay.io/prometheuscommunity/postgres-exporter:v0.12.0 - restart: on-failure:5 - environment: - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} - - DATA_SOURCE_URI=postgres1:5432/postgres?sslmode=disable - - DATA_SOURCE_USER=${POSTGRES_USER:-postgres} - - DATA_SOURCE_PASS=${POSTGRES_PASSWORD:-test123} - - PG_EXPORTER_EXTEND_QUERY_PATH=/etc/pgexporter/queries.yml - volumes: - - ./monitoring/configuration/postgres-exporter.yml:/etc/pgexporter/postgres-exporter.yml:Z - - ./monitoring/configuration/pg-exporter-queries.yml:/etc/pgexporter/queries.yml:Z - command: - # Both the config file and 'DATA_SOURCE_NAME' should contain valid connection info - - --config.file=/etc/pgexporter/postgres-exporter.yml - depends_on: - postgres1: - condition: service_healthy - networks: - - simulation + # postgres4: + # # This service is used when the Waku node has the 'store' protocol enabled + # # and the store-message-db-url is set to use Postgres + # image: postgres:15.4-alpine3.18 + # restart: on-failure:5 + # environment: + # - POSTGRES_USER=${POSTGRES_USER:-postgres} + # - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} + # volumes: + # - ./postgres_cfg/postgresql.conf:/etc/postgresql/postgresql.conf:Z + # - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z + # - ${PG_DATA_DIR:-./postgresql4}:/var/lib/postgresql/data:Z + # command: postgres -c config_file=/etc/postgresql/postgresql.conf + # ports: + # - 0.0.0.0:5435:5432 + # networks: + # - simulation + # healthcheck: + # test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"] + # interval: 30s + # timeout: 60s + # retries: 5 + # start_period: 80s + + # postgres-exporter: + # # Service aimed to scrape information from Postgres and post it to Prometeus + # image: quay.io/prometheuscommunity/postgres-exporter:v0.12.0 + # restart: on-failure:5 + # environment: + # - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-test123} + # - DATA_SOURCE_URI=postgres1:5432/postgres?sslmode=disable + # - DATA_SOURCE_USER=${POSTGRES_USER:-postgres} + # - DATA_SOURCE_PASS=${POSTGRES_PASSWORD:-test123} + # - PG_EXPORTER_EXTEND_QUERY_PATH=/etc/pgexporter/queries.yml + # volumes: + # - ./monitoring/configuration/postgres-exporter.yml:/etc/pgexporter/postgres-exporter.yml:Z + # - ./monitoring/configuration/pg-exporter-queries.yml:/etc/pgexporter/queries.yml:Z + # command: + # # Both the config file and 'DATA_SOURCE_NAME' should contain valid connection info + # - --config.file=/etc/pgexporter/postgres-exporter.yml + # depends_on: + # postgres1: + # condition: service_healthy + # networks: + # - simulation prometheus: image: prom/prometheus:latest diff --git a/monitoring/prometheus-config.yml b/monitoring/prometheus-config.yml index ccf106f..8a47d6a 100644 --- a/monitoring/prometheus-config.yml +++ b/monitoring/prometheus-config.yml @@ -20,9 +20,11 @@ scrape_configs: - waku-simulator_nwaku_store_pg1_1:8008 - waku-simulator_nwaku_store_pg2_1:8008 - waku-simulator_nwaku_store_pg3_1:8011 + - waku-simulator_nwaku_store_pg4_1:8011 - waku-simulator_postgres1_1:8008 - waku-simulator_postgres2_1:8008 - waku-simulator_postgres3_1:8008 + - waku-simulator_postgres4_1:8008 - waku-simulator_nwaku_1:8008 - waku-simulator_nwaku_2:8008 - waku-simulator_nwaku_3:8008 diff --git a/run_nwaku_store_postgres1.sh b/run_nwaku_store_postgres1.sh index e63c14f..8cd4ca9 100644 --- a/run_nwaku_store_postgres1.sh +++ b/run_nwaku_store_postgres1.sh @@ -38,10 +38,9 @@ exec /usr/bin/wakunode\ --ports-shift=0\ --nat=extip:${IP}\ --store=true\ - --store-message-retention-policy=size:1Gb\ + --store-message-retention-policy=size:40MB\ --store-message-db-url="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres1:5432/postgres"\ --store-sync=true\ - --store-sync-interval=300\ - --store-sync-range=3600\ - --store-sync-relay-jitter=0\ + --store-sync-interval=${WAKU_SYNC_INTERVAL}\ + --store-sync-range=${WAKU_SYNC_RANGE}\ --nodekey=5978783f8b1a16795032371fff7a526af352d9dca38179af7d71c0122942daa1 \ No newline at end of file diff --git a/run_nwaku_store_postgres2.sh b/run_nwaku_store_postgres2.sh index b53acb3..a55faae 100644 --- a/run_nwaku_store_postgres2.sh +++ b/run_nwaku_store_postgres2.sh @@ -37,11 +37,10 @@ exec /usr/bin/wakunode\ --cluster-id=16\ --ports-shift=0\ --store=true\ - --store-message-retention-policy=size:1GB\ + --store-message-retention-policy=size:40MB\ --nat=extip:${IP}\ --store-message-db-url="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres2:5432/postgres"\ --store-sync=true\ - --store-sync-interval=300\ - --store-sync-range=3600\ - --store-sync-relay-jitter=0\ + --store-sync-interval=${WAKU_SYNC_INTERVAL}\ + --store-sync-range=${WAKU_SYNC_RANGE}\ --nodekey=5978783f8b1a16795032371fff7a526af352d9dca38179af7d71c0122942daa3 \ No newline at end of file diff --git a/run_nwaku_store_postgres3.sh b/run_nwaku_store_postgres3.sh new file mode 100644 index 0000000..d2243fe --- /dev/null +++ b/run_nwaku_store_postgres3.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/') + +echo "I am a nwaku store node" + +RETRIES=${RETRIES:=10} + +while [ -z "${BOOTSTRAP_ENR}" ] && [ ${RETRIES} -ge 0 ]; do + BOOTSTRAP_ENR=$(wget -qO- http://bootstrap:8645/debug/v1/info --header='Content-Type:application/json' 2> /dev/null | sed 's/.*"enrUri":"\([^"]*\)".*/\1/'); + echo "Bootstrap node not ready, retrying (retries left: ${RETRIES})" + sleep 1 + RETRIES=$(( $RETRIES - 1 )) +done + +if [ -z "${BOOTSTRAP_ENR}" ]; then + echo "Could not get BOOTSTRAP_ENR and none provided. Failing" + exit 1 +fi + +echo "Using bootstrap node: ${BOOTSTRAP_ENR}" +exec /usr/bin/wakunode\ + --relay=false\ + --lightpush=true\ + --max-connections=50\ + --rest=true\ + --rest-address=0.0.0.0\ + --rest-port=8645\ + --dns-discovery=true\ + --discv5-discovery=true\ + --discv5-enr-auto-update=True\ + --log-level=TRACE\ + --metrics-server=True\ + --metrics-server-address=0.0.0.0\ + --discv5-bootstrap-node=${BOOTSTRAP_ENR}\ + --pubsub-topic=/waku/2/rs/16/32\ + --cluster-id=16\ + --ports-shift=3\ + --store=true\ + --store-message-retention-policy=size:40MB\ + --nat=extip:${IP}\ + --store-message-db-url="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres3:5432/postgres"\ + --store-sync=true\ + --store-sync-interval=${WAKU_SYNC_INTERVAL}\ + --store-sync-range=${WAKU_SYNC_RANGE}\ + --nodekey=5978783f8b1a16795032371fff7a526af352d9dca38179af7d71c0122942da5b \ No newline at end of file diff --git a/run_nwaku_store_postgres4.sh b/run_nwaku_store_postgres4.sh new file mode 100644 index 0000000..f6920a3 --- /dev/null +++ b/run_nwaku_store_postgres4.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +IP=$(ip a | grep "inet " | grep -Fv 127.0.0.1 | sed 's/.*inet \([^/]*\).*/\1/') + +echo "I am a nwaku store node" + +RETRIES=${RETRIES:=10} + +while [ -z "${BOOTSTRAP_ENR}" ] && [ ${RETRIES} -ge 0 ]; do + BOOTSTRAP_ENR=$(wget -qO- http://bootstrap:8645/debug/v1/info --header='Content-Type:application/json' 2> /dev/null | sed 's/.*"enrUri":"\([^"]*\)".*/\1/'); + echo "Bootstrap node not ready, retrying (retries left: ${RETRIES})" + sleep 1 + RETRIES=$(( $RETRIES - 1 )) +done + +if [ -z "${BOOTSTRAP_ENR}" ]; then + echo "Could not get BOOTSTRAP_ENR and none provided. Failing" + exit 1 +fi + +echo "Using bootstrap node: ${BOOTSTRAP_ENR}" +exec /usr/bin/wakunode\ + --relay=true\ + --lightpush=true\ + --max-connections=50\ + --rest=true\ + --rest-address=0.0.0.0\ + --rest-port=8645\ + --dns-discovery=true\ + --discv5-discovery=true\ + --discv5-enr-auto-update=True\ + --log-level=TRACE\ + --metrics-server=True\ + --metrics-server-address=0.0.0.0\ + --discv5-bootstrap-node=${BOOTSTRAP_ENR}\ + --pubsub-topic=/waku/2/rs/16/32\ + --cluster-id=16\ + --ports-shift=3\ + --store=true\ + --store-message-retention-policy=size:40MB\ + --nat=extip:${IP}\ + --store-message-db-url="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres3:5432/postgres"\ + --store-sync=true\ + --store-sync-interval=${WAKU_SYNC_INTERVAL}\ + --store-sync-range=${WAKU_SYNC_RANGE}\ + --nodekey=5978783f8b1a16795032371fff7a526af352d9dca38179af7d71c0122942aa5b \ No newline at end of file