From b17608f6a4ec7b96b21ab50d7408674103f33a7f Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Fri, 14 Jun 2024 13:50:24 +0530 Subject: [PATCH] Add compose file and stack instructions for sushiswap --- .../docker-compose-watcher-sushiswap.yml | 80 ++++++++++++++ .../stacks/sushiswap/README.md | 104 ++++++++++++++++++ .../stacks/sushiswap/stack.yml | 8 ++ 3 files changed, 192 insertions(+) create mode 100644 stacks/stack-orchestrator/compose/docker-compose-watcher-sushiswap.yml create mode 100644 stacks/stack-orchestrator/stacks/sushiswap/README.md create mode 100644 stacks/stack-orchestrator/stacks/sushiswap/stack.yml diff --git a/stacks/stack-orchestrator/compose/docker-compose-watcher-sushiswap.yml b/stacks/stack-orchestrator/compose/docker-compose-watcher-sushiswap.yml new file mode 100644 index 0000000..79246f7 --- /dev/null +++ b/stacks/stack-orchestrator/compose/docker-compose-watcher-sushiswap.yml @@ -0,0 +1,80 @@ +version: '3.2' + +services: + sushiswap-watcher-db: + restart: unless-stopped + image: postgres:14-alpine + environment: + - POSTGRES_USER=vdbm + - POSTGRES_MULTIPLE_DATABASES=sushiswap-watcher,sushiswap-watcher-job-queue + - POSTGRES_EXTENSION=sushiswap-watcher-job-queue:pgcrypto + - POSTGRES_PASSWORD=password + volumes: + - ../config/postgresql/multiple-postgressql-databases.sh:/docker-entrypoint-initdb.d/multiple-postgressql-databases.sh + - sushiswap_watcher_db_data:/var/lib/postgresql/data + ports: + - "5432" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "5432"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + + sushiswap-watcher-job-runner: + restart: unless-stopped + depends_on: + sushiswap-watcher-db: + condition: service_healthy + image: cerc/watcher-sushiswap:local + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_ETH_RPC_ENDPOINTS: ${CERC_ETH_RPC_ENDPOINTS} + working_dir: /app/packages-watcher + command: ["bash", "./start-job-runner.sh"] + volumes: + - ../config/watcher-sushiswap/watcher-config-template.toml:/app/packages-watcher/environments/watcher-config-template.toml + - ../config/common/start-job-runner.sh:/app/packages-watcher/start-job-runner.sh + ports: + - "9000:9000" + healthcheck: + test: ["CMD", "nc", "-vz", "127.0.0.1", "9000"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + sushiswap-watcher-server: + restart: unless-stopped + depends_on: + sushiswap-watcher-db: + condition: service_healthy + sushiswap-watcher-job-runner: + condition: service_healthy + image: cerc/watcher-sushiswap:local + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_ETH_RPC_ENDPOINTS: ${CERC_ETH_RPC_ENDPOINTS} + working_dir: /app/packages-watcher + command: ["bash", "./start-server.sh"] + volumes: + - ../config/watcher-sushiswap/watcher-config-template.toml:/app/packages-watcher/environments/watcher-config-template.toml + - ../config/common/start-server.sh:/app/packages-watcher/start-server.sh + - sushiswap_watcher_gql_logs_data:/app/packages-watcher/gql-logs + ports: + - "3008" + - "9001" + healthcheck: + test: ["CMD", "nc", "-vz", "127.0.0.1", "3008"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + +volumes: + sushiswap_watcher_db_data: + sushiswap_watcher_gql_logs_data: diff --git a/stacks/stack-orchestrator/stacks/sushiswap/README.md b/stacks/stack-orchestrator/stacks/sushiswap/README.md new file mode 100644 index 0000000..128656b --- /dev/null +++ b/stacks/stack-orchestrator/stacks/sushiswap/README.md @@ -0,0 +1,104 @@ +# SushiSwap Watcher + +## Clone the stack repo + +```bash +laconic-so fetch-stack git.vdb.to/cerc-io/sushiswap-watcher-ts +``` + +## Build the container image + +```bash +laconic-so --stack ~/cerc/sushiswap-watcher-ts/stacks/stack-orchestrator/stacks/sushiswap build-containers +``` + +## Create a spec file for the deployment + +```bash +laconic-so --stack ~/cerc/sushiswap-watcher-ts/stacks/stack-orchestrator/stacks/sushiswap deploy init --output sushiswap-spec.yml +``` + +### Ports + +Edit `network` in the spec file to map container ports to host ports as required: + +```yml +... +network: + ports: + sushiswap-watcher-db: + - 15432:5432 + sushiswap-watcher-job-runner: + - 9000:9000 + sushiswap-watcher-server: + - 3008:3008 + - 9001:9001 +``` + +## Create a deployment from the spec file + +```bash +laconic-so --stack ~/cerc/sushiswap-watcher-ts/stacks/stack-orchestrator/stacks/sushiswap deploy create --spec-file sushiswap-spec.yml --deployment-dir sushiswap-deployment +``` + +### Configuration + +Inside deployment directory, open the `config.env` file and set following env variables: + +```bash +# External Filecoin (ETH RPC) endpoint to point the watcher to +CERC_ETH_RPC_ENDPOINTS=https://example-lotus-endpoint-1/rpc/v1,https://example-lotus-endpoint-2/rpc/v1 +``` + +## Start the deployment + +```bash +laconic-so deployment --dir sushiswap-deployment start +``` + +* To list down and monitor the running containers: + + ```bash + # With status + docker ps -a + + # Check logs for a container + docker logs -f + ``` + +* Open the GQL playground at + + ```graphql + # Example query + query { + _meta { + block { + hash + number + timestamp + } + deployment + hasIndexingErrors + } + ``` + +## Clean up + +Stop all the sushiswap services running in background: + +```bash +# Only stop the docker containers +laconic-so deployment --dir sushiswap-deployment stop + +# Run 'start' to restart the deployment +``` + +To stop all the sushiswap services and also delete data: + +```bash +# Stop the docker containers +laconic-so deployment --dir sushiswap-deployment stop --delete-volumes + +# Remove deployment directory (deployment will have to be recreated for a re-run) +rm -r sushiswap-deployment +``` diff --git a/stacks/stack-orchestrator/stacks/sushiswap/stack.yml b/stacks/stack-orchestrator/stacks/sushiswap/stack.yml new file mode 100644 index 0000000..687b60d --- /dev/null +++ b/stacks/stack-orchestrator/stacks/sushiswap/stack.yml @@ -0,0 +1,8 @@ +version: "1.0" +name: sushiswap +description: "SushiSwap watcher stack" +repos: +containers: + - cerc/watcher-sushiswap +pods: + - watcher-sushiswap