diff --git a/stack_orchestrator/data/compose/docker-compose-watcher-sushiswap-v3.yml b/stack_orchestrator/data/compose/docker-compose-watcher-sushiswap-v3.yml index a4b1b035..db367420 100644 --- a/stack_orchestrator/data/compose/docker-compose-watcher-sushiswap-v3.yml +++ b/stack_orchestrator/data/compose/docker-compose-watcher-sushiswap-v3.yml @@ -21,17 +21,43 @@ services: retries: 15 start_period: 10s - sushiswap-v3-watcher-server: + sushiswap-v3-watcher-job-runner: 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} + 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: 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"] + command: ["bash", "./start-server.sh"] 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 diff --git a/stack_orchestrator/data/config/watcher-sushiswap-v3/start-job-runner.sh b/stack_orchestrator/data/config/watcher-sushiswap-v3/start-job-runner.sh new file mode 100755 index 00000000..819b1096 --- /dev/null +++ b/stack_orchestrator/data/config/watcher-sushiswap-v3/start-job-runner.sh @@ -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 diff --git a/stack_orchestrator/data/config/watcher-sushiswap-v3/start-server.sh b/stack_orchestrator/data/config/watcher-sushiswap-v3/start-server.sh index 3bcc6d91..1b14f2e3 100755 --- a/stack_orchestrator/data/config/watcher-sushiswap-v3/start-server.sh +++ b/stack_orchestrator/data/config/watcher-sushiswap-v3/start-server.sh @@ -6,17 +6,15 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then fi 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 -# 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_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" > /home/prathamesh/deepstack/stack-orchestrator/stack_orchestrator/data/config/watcher-sushiswap-v3/local.toml - +echo "$WATCHER_CONFIG" > environments/local.toml echo "Initializing watcher..." yarn fill --start-block $SUSHISWAP_START_BLOCK --end-block $((SUSHISWAP_START_BLOCK + 1)) diff --git a/stack_orchestrator/data/stacks/sushiswap-v3/README.md b/stack_orchestrator/data/stacks/sushiswap-v3/README.md index dac19e26..7116a6d9 100644 --- a/stack_orchestrator/data/stacks/sushiswap-v3/README.md +++ b/stack_orchestrator/data/stacks/sushiswap-v3/README.md @@ -1,4 +1,4 @@ -# SushiSwap +# SushiSwap v3 Watcher ## Setup