Skip to content

Commit

Permalink
fix audius-cmd && replicate relay locally (#7462)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecsavvy authored Feb 6, 2024
1 parent ba54eb2 commit ae4edfe
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 13 deletions.
5 changes: 4 additions & 1 deletion dev-tools/compose/docker-compose.pedalboard.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ services:
- pedalboard

relay:
container_name: relay
build:
context: ${PROJECT_ROOT}
dockerfile: ${PROJECT_ROOT}/packages/discovery-provider/plugins/pedalboard/docker/Dockerfile.prod
args:
app_name: relay
TURBO_TEAM: '${TURBO_TEAM}'
TURBO_TOKEN: '${TURBO_TOKEN}'
env_file: .env
restart: always
deploy:
mode: replicated
replicas: '${DISCOVERY_PROVIDER_REPLICAS}'

solana-relay:
build:
Expand Down
8 changes: 4 additions & 4 deletions dev-tools/compose/nginx_ingress.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ server {

location ~ ^/relay(/.*)?$ {
resolver 127.0.0.11 valid=30s;
proxy_pass http://relay:6001/relay$1;
proxy_pass http://audius-protocol-relay-1:6001/relay$1;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Expand Down Expand Up @@ -84,7 +84,7 @@ server {

location ~ ^/relay(/.*)?$ {
resolver 127.0.0.11 valid=30s;
proxy_pass http://relay:6001/relay$1;
proxy_pass http://audius-protocol-relay-2:6001/relay$1;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ server {

location ~ ^/relay(/.*)?$ {
resolver 127.0.0.11 valid=30s;
proxy_pass http://relay:6001/relay$1;
proxy_pass http://audius-protocol-relay-3:6001/relay$1;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Expand Down Expand Up @@ -329,7 +329,7 @@ server {

location ~ ^/relay(/.*)?$ {
resolver 127.0.0.11 valid=30s;
proxy_pass http://relay:6001/relay$1;
proxy_pass http://relay-1:6001/relay$1;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Expand Down
6 changes: 5 additions & 1 deletion dev-tools/startup/discovery-provider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ if [[ "$audius_redis_url" == "" ]]; then
export audius_redis_url="redis://audius-protocol-discovery-provider-redis-${replica}:6379/00"
fi

if [[ "$audius_relay_host" == "" ]]; then
export audius_relay_host="http://audius-protocol-relay-${replica}:6001/relay"
fi

export audius_enable_rsyslog=false

export audius_discprov_url="http://audius-protocol-discovery-provider-${replica}"
Expand All @@ -25,4 +29,4 @@ fi
./scripts/register.py &

# Create sender for current DN
../../node_modules/.bin/ts-node ./scripts/createSender.ts ${replica} &
../../node_modules/.bin/ts-node ./scripts/createSender.ts ${replica} &
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "tsc",
"build:watch": "tsc --watch",
"clean": "rm -rf dist",
"dev": "ts-node-dev --respawn ./src/index.ts",
"dev": "nodemon ./dist/index.js",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"lint": "tsc --noEmit && eslint \"src/**/*.ts*\"",
"sandbox": "npx ts-node ./src/scripts/sandbox.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ ENV APP_NAME=${app_name}

WORKDIR /app/packages/discovery-provider/plugins/pedalboard/apps/${APP_NAME}

RUN apk add --no-cache curl

HEALTHCHECK --interval=3s \
--timeout=30s \
--start-period=5s \
--retries=3 \
CMD curl -f http://localhost:6001/relay/health || exit 1

CMD sh ../../docker/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ COPY --from=installer /app .

WORKDIR /app/packages/discovery-provider/plugins/pedalboard/apps/${APP_NAME}

RUN apk add --no-cache curl

HEALTHCHECK --interval=3s \
--timeout=30s \
--start-period=5s \
--retries=3 \
CMD curl -f http://localhost:6001/relay/health || exit 1

CMD npm run start
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ if nslookup "$elasticsearch_host" >/dev/null 2>&1; then
export audius_elasticsearch_url="http://${elasticsearch_host}:9200"
fi

npm run dev
npm run dev
13 changes: 8 additions & 5 deletions packages/discovery-provider/src/queries/get_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
from src.utils.web3_provider import get_web3

LOCAL_RPC = "http://chain:8545"
RELAY_PLUGIN = "http://relay:6001/relay"


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -116,7 +115,11 @@ def _get_query_insights():


def _get_relay_health():
relay_health = requests.get(RELAY_PLUGIN + "/health")
relay_plugin = os.getenv(
"audius_relay_host",
"http://relay:6001/relay",
)
relay_health = requests.get(relay_plugin + "/health")
relay_res = relay_health.json()
return relay_res

Expand Down Expand Up @@ -361,9 +364,9 @@ def get_health(args: GetHealthArgs, use_redis_cache: bool = True) -> Tuple[Dict,
"final_poa_block": final_poa_block,
"network": {
"discovery_nodes_with_owner": discovery_nodes,
"discovery_nodes": [d["endpoint"] for d in discovery_nodes]
if discovery_nodes
else None,
"discovery_nodes": (
[d["endpoint"] for d in discovery_nodes] if discovery_nodes else None
),
"content_nodes": content_nodes,
},
}
Expand Down

0 comments on commit ae4edfe

Please sign in to comment.