Add services for watcher db and server

This commit is contained in:
Prathamesh Musale 2023-11-10 11:39:54 +05:30
parent dd0cf5c356
commit 7ce7485da2
4 changed files with 82 additions and 6 deletions

View File

@ -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:

View File

@ -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

View File

@ -47,11 +47,11 @@
[database] [database]
type = "postgres" type = "postgres"
host = "localhost" host = "sushiswap-v3-watcher-db"
port = 5432 port = 5432
database = "sushiswap-v3-watcher-ts" database = "sushiswap-v3-watcher"
username = "postgres" username = "vdbm"
password = "postgres" password = "password"
synchronize = true synchronize = true
logging = false logging = false
@ -76,7 +76,7 @@
deleteOnStart = false deleteOnStart = false
[jobQueue] [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 maxCompletionLagInSecs = 300
jobDelayInMilliSecs = 100 jobDelayInMilliSecs = 100
eventsInBatch = 50 eventsInBatch = 50

View File

@ -2,7 +2,7 @@ version: "1.0"
name: sushiswap-v3 name: sushiswap-v3
description: "SushiSwap v3 watcher stack" description: "SushiSwap v3 watcher stack"
repos: repos:
- github.com/cerc-io/sushiswap-v3-watcher-ts - github.com/cerc-io/sushiswap-v3-watcher-ts@v0.1.0
containers: containers:
- cerc/watcher-sushiswap-v3 - cerc/watcher-sushiswap-v3
pods: pods: