From 6d08758bc5205e4d75948f9c7aaac638d7713884 Mon Sep 17 00:00:00 2001
From: nabarun <nabarun@deepstacksoft.com>
Date: Thu, 4 May 2023 10:39:57 +0530
Subject: [PATCH] Add all azimuth watchers in stack

---
 .../docker-compose-watcher-azimuth.yml        | 166 +++++++++++++++++-
 .../watcher-azimuth/gateway-watchers.json     |  24 +++
 .../config/watcher-azimuth/start-server.sh    |   1 -
 .../cerc-watcher-azimuth/Dockerfile           |   3 +
 4 files changed, 190 insertions(+), 4 deletions(-)

diff --git a/app/data/compose/docker-compose-watcher-azimuth.yml b/app/data/compose/docker-compose-watcher-azimuth.yml
index 094eca94..54ee6d52 100644
--- a/app/data/compose/docker-compose-watcher-azimuth.yml
+++ b/app/data/compose/docker-compose-watcher-azimuth.yml
@@ -7,8 +7,8 @@ services:
     image: postgres:14-alpine
     environment:
       - POSTGRES_USER=vdbm
-      - POSTGRES_MULTIPLE_DATABASES=azimuth-watcher,azimuth-watcher-job-queue,censures-watcher,censures-watcher-job-queue,claims-watcher,claims-watcher-job-queue,conditional-star-release-watcher,conditional-star-release-watcher-job-queue,delegated-watcher,delegated-watcher-job-queue,ecliptic-watcher,ecliptic-watcher-job-queue,linear-star-release-watcher,linear-star-release-watcher-job-queue,polls-watcher,polls-watcher-job-queue
-      - POSTGRES_EXTENSION=azimuth-watcher-job-queue:pgcrypto,censures-watcher-job-queue:pgcrypto,claims-watcher-job-queue:pgcrypto,conditional-star-release-watcher-job-queue:pgcrypto,delegated-watcher-job-queue:pgcrypto,ecliptic-watcher-job-queue:pgcrypto,linear-star-release-watcher-job-queue:pgcrypto,polls-watcher-job-queue:pgcrypto,
+      - POSTGRES_MULTIPLE_DATABASES=azimuth-watcher,azimuth-watcher-job-queue,censures-watcher,censures-watcher-job-queue,claims-watcher,claims-watcher-job-queue,conditional-star-release-watcher,conditional-star-release-watcher-job-queue,delegated-sending-watcher,delegated-sending-watcher-job-queue,ecliptic-watcher,ecliptic-watcher-job-queue,linear-star-release-watcher,linear-star-release-watcher-job-queue,polls-watcher,polls-watcher-job-queue
+      - POSTGRES_EXTENSION=azimuth-watcher-job-queue:pgcrypto,censures-watcher-job-queue:pgcrypto,claims-watcher-job-queue:pgcrypto,conditional-star-release-watcher-job-queue:pgcrypto,delegated-sending-watcher-job-queue:pgcrypto,ecliptic-watcher-job-queue:pgcrypto,linear-star-release-watcher-job-queue:pgcrypto,polls-watcher-job-queue:pgcrypto,
       - POSTGRES_PASSWORD=password
     volumes:
       - ../config/postgresql/multiple-postgressql-databases.sh:/docker-entrypoint-initdb.d/multiple-postgressql-databases.sh
@@ -37,6 +37,8 @@ services:
       - ../config/watcher-azimuth/watcher-config.toml:/app/packages/azimuth-watcher/environments/watcher-config.toml
       - ../config/watcher-azimuth/merge-toml.js:/app/packages/azimuth-watcher/merge-toml.js
       - ../config/watcher-azimuth/start-server.sh:/app/packages/azimuth-watcher/start-server.sh
+    ports:
+      - "3001"
     healthcheck:
       test: ["CMD", "nc", "-vz", "localhost", "3001"]
       interval: 20s
@@ -46,7 +48,7 @@ services:
     extra_hosts:
       - "host.docker.internal:host-gateway"
 
-    # Starts the censures-watcher server
+  # Starts the censures-watcher server
   censures-watcher-server:
     image: cerc/watcher-azimuth:local
     restart: unless-stopped
@@ -70,6 +72,150 @@ services:
     extra_hosts:
       - "host.docker.internal:host-gateway"
 
+  # Starts the claims-watcher server
+  claims-watcher-server:
+    image: cerc/watcher-azimuth:local
+    restart: unless-stopped
+    depends_on:
+      watcher-db:
+        condition: service_healthy
+    environment:
+      CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
+    working_dir: /app/packages/claims-watcher
+    command: "./start-server.sh"
+    volumes:
+      - ../config/watcher-azimuth/watcher-config.toml:/app/packages/claims-watcher/environments/watcher-config.toml
+      - ../config/watcher-azimuth/merge-toml.js:/app/packages/claims-watcher/merge-toml.js
+      - ../config/watcher-azimuth/start-server.sh:/app/packages/claims-watcher/start-server.sh
+    healthcheck:
+      test: ["CMD", "nc", "-vz", "localhost", "3003"]
+      interval: 20s
+      timeout: 5s
+      retries: 15
+      start_period: 5s
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
+
+  # Starts the conditional-star-release-watcher server
+  conditional-star-release-watcher-server:
+    image: cerc/watcher-azimuth:local
+    restart: unless-stopped
+    depends_on:
+      watcher-db:
+        condition: service_healthy
+    environment:
+      CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
+    working_dir: /app/packages/conditional-star-release-watcher
+    command: "./start-server.sh"
+    volumes:
+      - ../config/watcher-azimuth/watcher-config.toml:/app/packages/conditional-star-release-watcher/environments/watcher-config.toml
+      - ../config/watcher-azimuth/merge-toml.js:/app/packages/conditional-star-release-watcher/merge-toml.js
+      - ../config/watcher-azimuth/start-server.sh:/app/packages/conditional-star-release-watcher/start-server.sh
+    healthcheck:
+      test: ["CMD", "nc", "-vz", "localhost", "3004"]
+      interval: 20s
+      timeout: 5s
+      retries: 15
+      start_period: 5s
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
+
+  # Starts the delegated-sending-watcher server
+  delegated-sending-watcher-server:
+    image: cerc/watcher-azimuth:local
+    restart: unless-stopped
+    depends_on:
+      watcher-db:
+        condition: service_healthy
+    environment:
+      CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
+    working_dir: /app/packages/delegated-sending-watcher
+    command: "./start-server.sh"
+    volumes:
+      - ../config/watcher-azimuth/watcher-config.toml:/app/packages/delegated-sending-watcher/environments/watcher-config.toml
+      - ../config/watcher-azimuth/merge-toml.js:/app/packages/delegated-sending-watcher/merge-toml.js
+      - ../config/watcher-azimuth/start-server.sh:/app/packages/delegated-sending-watcher/start-server.sh
+    healthcheck:
+      test: ["CMD", "nc", "-vz", "localhost", "3005"]
+      interval: 20s
+      timeout: 5s
+      retries: 15
+      start_period: 5s
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
+
+  # Starts the ecliptic-watcher server
+  ecliptic-watcher-server:
+    image: cerc/watcher-azimuth:local
+    restart: unless-stopped
+    depends_on:
+      watcher-db:
+        condition: service_healthy
+    environment:
+      CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
+    working_dir: /app/packages/ecliptic-watcher
+    command: "./start-server.sh"
+    volumes:
+      - ../config/watcher-azimuth/watcher-config.toml:/app/packages/ecliptic-watcher/environments/watcher-config.toml
+      - ../config/watcher-azimuth/merge-toml.js:/app/packages/ecliptic-watcher/merge-toml.js
+      - ../config/watcher-azimuth/start-server.sh:/app/packages/ecliptic-watcher/start-server.sh
+    healthcheck:
+      test: ["CMD", "nc", "-vz", "localhost", "3006"]
+      interval: 20s
+      timeout: 5s
+      retries: 15
+      start_period: 5s
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
+
+  # Starts the linear-star-release-watcher server
+  linear-star-release-watcher-server:
+    image: cerc/watcher-azimuth:local
+    restart: unless-stopped
+    depends_on:
+      watcher-db:
+        condition: service_healthy
+    environment:
+      CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
+    working_dir: /app/packages/linear-star-release-watcher
+    command: "./start-server.sh"
+    volumes:
+      - ../config/watcher-azimuth/watcher-config.toml:/app/packages/linear-star-release-watcher/environments/watcher-config.toml
+      - ../config/watcher-azimuth/merge-toml.js:/app/packages/linear-star-release-watcher/merge-toml.js
+      - ../config/watcher-azimuth/start-server.sh:/app/packages/linear-star-release-watcher/start-server.sh
+    healthcheck:
+      test: ["CMD", "nc", "-vz", "localhost", "3007"]
+      interval: 20s
+      timeout: 5s
+      retries: 15
+      start_period: 5s
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
+
+  # Starts the polls-watcher server
+  polls-watcher-server:
+    image: cerc/watcher-azimuth:local
+    restart: unless-stopped
+    depends_on:
+      watcher-db:
+        condition: service_healthy
+    environment:
+      CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
+    working_dir: /app/packages/polls-watcher
+    command: "./start-server.sh"
+    volumes:
+      - ../config/watcher-azimuth/watcher-config.toml:/app/packages/polls-watcher/environments/watcher-config.toml
+      - ../config/watcher-azimuth/merge-toml.js:/app/packages/polls-watcher/merge-toml.js
+      - ../config/watcher-azimuth/start-server.sh:/app/packages/polls-watcher/start-server.sh
+    healthcheck:
+      test: ["CMD", "nc", "-vz", "localhost", "3008"]
+      interval: 20s
+      timeout: 5s
+      retries: 15
+      start_period: 5s
+    extra_hosts:
+      - "host.docker.internal:host-gateway"
+
   # Starts the gateway-server for proxying queries
   gateway-server:
     image: cerc/watcher-azimuth:local
@@ -77,6 +223,20 @@ services:
     depends_on:
       azimuth-watcher-server:
         condition: service_healthy
+      censures-watcher-server:
+        condition: service_healthy
+      claims-watcher-server:
+        condition: service_healthy
+      conditional-star-release-watcher-server:
+        condition: service_healthy
+      delegated-sending-watcher-server:
+        condition: service_healthy
+      ecliptic-watcher-server:
+        condition: service_healthy
+      linear-star-release-watcher-server:
+        condition: service_healthy
+      polls-watcher-server:
+        condition: service_healthy
     environment:
       CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
     working_dir: /app/packages/gateway-server
diff --git a/app/data/config/watcher-azimuth/gateway-watchers.json b/app/data/config/watcher-azimuth/gateway-watchers.json
index 550da348..40687556 100644
--- a/app/data/config/watcher-azimuth/gateway-watchers.json
+++ b/app/data/config/watcher-azimuth/gateway-watchers.json
@@ -6,5 +6,29 @@
   {
     "endpoint": "http://censures-watcher-server:3002/graphql",
     "prefix": "censures"
+  },
+  {
+    "endpoint": "http://claims-watcher-server:3003/graphql",
+    "prefix": "claims"
+  },
+  {
+    "endpoint": "http://conditional-star-release-watcher-server:3004/graphql",
+    "prefix": "conditionalStarRelease"
+  },
+  {
+    "endpoint": "http://delegated-sending-watcher-server:3005/graphql",
+    "prefix": "delegatedSending"
+  },
+  {
+    "endpoint": "http://ecliptic-watcher-server:3006/graphql",
+    "prefix": "ecliptic"
+  },
+  {
+    "endpoint": "http://linear-star-release-watcher-server:3007/graphql",
+    "prefix": "linearStarRelease"
+  },
+  {
+    "endpoint": "http://polls-watcher-server:3008/graphql",
+    "prefix": "polls"
   }
 ]
diff --git a/app/data/config/watcher-azimuth/start-server.sh b/app/data/config/watcher-azimuth/start-server.sh
index 5df6a2d1..c49f2634 100755
--- a/app/data/config/watcher-azimuth/start-server.sh
+++ b/app/data/config/watcher-azimuth/start-server.sh
@@ -21,7 +21,6 @@ echo "Using IPLD GQL endpoint ${CERC_IPLD_GQL}"
 # echo "$WATCHER_CONFIG" > environments/watcher-config.toml
 
 # Merge SO watcher config with existing config file
-yarn add --dev --ignore-scripts toml-js
 node merge-toml.js
 
 
diff --git a/app/data/container-build/cerc-watcher-azimuth/Dockerfile b/app/data/container-build/cerc-watcher-azimuth/Dockerfile
index 4cd65a0d..8c299257 100644
--- a/app/data/container-build/cerc-watcher-azimuth/Dockerfile
+++ b/app/data/container-build/cerc-watcher-azimuth/Dockerfile
@@ -8,3 +8,6 @@ COPY . .
 
 RUN echo "Building azimuth-watcher-ts" && \
     yarn && yarn build
+
+RUN echo "Install toml-js to update watcher config files" && \
+    yarn add --dev toml-js