diff --git a/stack_orchestrator/data/compose/docker-compose-watcher-sushiswap-v3.yml b/stack_orchestrator/data/compose/docker-compose-watcher-sushiswap-v3.yml new file mode 100644 index 00000000..a4b1b035 --- /dev/null +++ b/stack_orchestrator/data/compose/docker-compose-watcher-sushiswap-v3.yml @@ -0,0 +1,51 @@ +version: '3.2' + +services: + sushiswap-v3-watcher-db: + restart: unless-stopped + image: postgres:14-alpine + environment: + - POSTGRES_USER=vdbm + - POSTGRES_MULTIPLE_DATABASES=sushiswap-v3-watcher,sushiswap-v3-watcher-job-queue + - POSTGRES_EXTENSION=sushiswap-v3-watcher-job-queue:pgcrypto + - POSTGRES_PASSWORD=password + volumes: + - ../config/postgresql/multiple-postgressql-databases.sh:/docker-entrypoint-initdb.d/multiple-postgressql-databases.sh + - sushiswap_v3_watcher_db_data:/var/lib/postgresql/data + ports: + - "127.0.0.1:15432:5432" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "5432"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + + sushiswap-v3-watcher-server: + restart: unless-stopped + depends_on: + sushiswap-v3-watcher-db: + condition: service_healthy + image: cerc/watcher-sushiswap-v3:local + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT} + SUSHISWAP_START_BLOCK: ${SUSHISWAP_START_BLOCK:- 2867560} + command: ["node", "--enable-source-maps", "dist/server.js"] + volumes: + - ../config/watcher-sushiswap-v3/watcher-config-template.toml:/app/environments/watcher-config-template.toml + - ../config/watcher-sushiswap-v3/start-server.sh:/app/start-server.sh + ports: + - "127.0.0.1:3008:3008" + - "127.0.0.1:9001:9001" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3008"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + +volumes: + sushiswap_v3_watcher_db_data: diff --git a/stack_orchestrator/data/config/watcher-sushiswap-v3/start-server.sh b/stack_orchestrator/data/config/watcher-sushiswap-v3/start-server.sh new file mode 100755 index 00000000..3bcc6d91 --- /dev/null +++ b/stack_orchestrator/data/config/watcher-sushiswap-v3/start-server.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi +set -u + +echo "Using RPC query endpoint ${CERC_ETH_RPC_ENDPOINT}" + +# Read in the config template TOML file and modify it +# WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml) +WATCHER_CONFIG_TEMPLATE=$(cat /home/prathamesh/deepstack/stack-orchestrator/stack_orchestrator/data/config/watcher-sushiswap-v3/watcher-config-template.toml) +WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \ + sed -E "s|REPLACE_WITH_CERC_ETH_RPC_ENDPOINT|${CERC_ETH_RPC_ENDPOINT}| ") + +# Write the modified content to a new file +echo "$WATCHER_CONFIG" > /home/prathamesh/deepstack/stack-orchestrator/stack_orchestrator/data/config/watcher-sushiswap-v3/local.toml + + +echo "Initializing watcher..." +yarn fill --start-block $SUSHISWAP_START_BLOCK --end-block $((SUSHISWAP_START_BLOCK + 1)) + +echo "Running server..." +DEBUG=vulcanize:* exec node --enable-source-maps dist/server.js diff --git a/stack_orchestrator/data/config/watcher-sushiswap-v3/watcher-config-template.toml b/stack_orchestrator/data/config/watcher-sushiswap-v3/watcher-config-template.toml index f18db181..5a811723 100644 --- a/stack_orchestrator/data/config/watcher-sushiswap-v3/watcher-config-template.toml +++ b/stack_orchestrator/data/config/watcher-sushiswap-v3/watcher-config-template.toml @@ -47,11 +47,11 @@ [database] type = "postgres" - host = "localhost" + host = "sushiswap-v3-watcher-db" port = 5432 - database = "sushiswap-v3-watcher-ts" - username = "postgres" - password = "postgres" + database = "sushiswap-v3-watcher" + username = "vdbm" + password = "password" synchronize = true logging = false @@ -76,7 +76,7 @@ deleteOnStart = false [jobQueue] - dbConnectionString = "postgres://postgres:postgres@localhost/sushiswap-v3-watcher-ts-job-queue" + dbConnectionString = "postgres://vdbm:password@sushiswap-v3-watcher-db/sushiswap-v3-watcher-job-queue" maxCompletionLagInSecs = 300 jobDelayInMilliSecs = 100 eventsInBatch = 50 diff --git a/stack_orchestrator/data/stacks/sushiswap-v3/stack.yml b/stack_orchestrator/data/stacks/sushiswap-v3/stack.yml index ecd9362e..a851ce51 100644 --- a/stack_orchestrator/data/stacks/sushiswap-v3/stack.yml +++ b/stack_orchestrator/data/stacks/sushiswap-v3/stack.yml @@ -2,7 +2,7 @@ version: "1.0" name: sushiswap-v3 description: "SushiSwap v3 watcher stack" repos: - - github.com/cerc-io/sushiswap-v3-watcher-ts + - github.com/cerc-io/sushiswap-v3-watcher-ts@v0.1.0 containers: - cerc/watcher-sushiswap-v3 pods: