Add service for watcher job-runner

This commit is contained in:
Prathamesh Musale 2023-11-10 11:47:51 +05:30
parent 7ce7485da2
commit 7b55da793f
4 changed files with 52 additions and 8 deletions

View File

@ -21,17 +21,43 @@ services:
retries: 15 retries: 15
start_period: 10s start_period: 10s
sushiswap-v3-watcher-server: sushiswap-v3-watcher-job-runner:
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
sushiswap-v3-watcher-db: sushiswap-v3-watcher-db:
condition: service_healthy condition: service_healthy
image: cerc/watcher-sushiswap-v3:local image: cerc/watcher-sushiswap-v3:local
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT}
command: ["bash", "./start-job-runner.sh"]
volumes:
- ../config/watcher-sushiswap-v3/watcher-config-template.toml:/app/environments/watcher-config-template.toml
- ../config/watcher-sushiswap-v3/start-job-runner.sh:/app/start-job-runner.sh
ports:
- "127.0.0.1:9000:9000"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "9000"]
interval: 20s
timeout: 5s
retries: 15
start_period: 5s
extra_hosts:
- "host.docker.internal:host-gateway"
sushiswap-v3-watcher-server:
restart: unless-stopped
depends_on:
sushiswap-v3-watcher-db:
condition: service_healthy
sushiswap-v3-watcher-job-runner:
condition: service_healthy
image: cerc/watcher-sushiswap-v3:local
environment: environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT} CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT}
SUSHISWAP_START_BLOCK: ${SUSHISWAP_START_BLOCK:- 2867560} SUSHISWAP_START_BLOCK: ${SUSHISWAP_START_BLOCK:- 2867560}
command: ["node", "--enable-source-maps", "dist/server.js"] command: ["bash", "./start-server.sh"]
volumes: volumes:
- ../config/watcher-sushiswap-v3/watcher-config-template.toml:/app/environments/watcher-config-template.toml - ../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 - ../config/watcher-sushiswap-v3/start-server.sh:/app/start-server.sh

View File

@ -0,0 +1,20 @@
#!/bin/sh
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
set -u
echo "Using ETH RPC 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=$(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" > environments/local.toml
echo "Running job-runner..."
DEBUG=vulcanize:* exec node --enable-source-maps dist/job-runner.js

View File

@ -6,17 +6,15 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
fi fi
set -u set -u
echo "Using RPC query endpoint ${CERC_ETH_RPC_ENDPOINT}" echo "Using ETH RPC endpoint ${CERC_ETH_RPC_ENDPOINT}"
# Read in the config template TOML file and modify it # Read in the config template TOML file and modify it
# WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml) 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" | \ WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \
sed -E "s|REPLACE_WITH_CERC_ETH_RPC_ENDPOINT|${CERC_ETH_RPC_ENDPOINT}| ") sed -E "s|REPLACE_WITH_CERC_ETH_RPC_ENDPOINT|${CERC_ETH_RPC_ENDPOINT}| ")
# Write the modified content to a new file # 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 "$WATCHER_CONFIG" > environments/local.toml
echo "Initializing watcher..." echo "Initializing watcher..."
yarn fill --start-block $SUSHISWAP_START_BLOCK --end-block $((SUSHISWAP_START_BLOCK + 1)) yarn fill --start-block $SUSHISWAP_START_BLOCK --end-block $((SUSHISWAP_START_BLOCK + 1))

View File

@ -1,4 +1,4 @@
# SushiSwap # SushiSwap v3 Watcher
## Setup ## Setup