Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DaMandal0rian committed Nov 1, 2024
1 parent f9c2f9e commit 39cad35
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 26 deletions.
27 changes: 22 additions & 5 deletions templates/terraform/subql/base/bootstrap_nova_subql_provisioner.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ resource "null_resource" "setup-nova-green-subql-nodes" {
# create subql dir
provisioner "remote-exec" {
inline = [
"mkdir -p /home/${var.ssh_user}/subql",
"mkdir -p /home/${var.ssh_user}/subql/postgresql",
"mkdir -p /home/${var.ssh_user}/subql/postgresql/{conf,data}",
"sudo mkdir -p /home/${var.ssh_user}/subql",
"sudo mkdir -p /home/${var.ssh_user}/subql/postgresql",
"sudo mkdir -p /home/${var.ssh_user}/subql/postgresql/conf",
"sudo mkdir -p /home/${var.ssh_user}/subql/postgresql/data",
"sudo chown -R ${var.ssh_user}:${var.ssh_user} /home/${var.ssh_user}/subql/ && sudo chmod -R 750 /home/${var.ssh_user}/subql/"
]
}
Expand Down Expand Up @@ -159,7 +160,6 @@ resource "null_resource" "start-nova-blue-subql-nodes" {
# run subql install script
"chmod +x /home/${var.ssh_user}/subql/install_subql_stack.sh",
"bash /home/${var.ssh_user}/subql/install_subql_stack.sh",
"echo 'Installation Complete'",

# create .env file
"grep -q '^NR_AGENT_IDENTIFIER=' /home/${var.ssh_user}/astral/.env && sed -i 's/^NR_AGENT_IDENTIFIER=.*/NR_AGENT_IDENTIFIER=subql-${var.nova-blue-subql-node-config.deployment-color}-${var.nova-blue-subql-node-config.network-name}/' /home/${var.ssh_user}/astral/.env || echo NR_AGENT_IDENTIFIER=subql-${var.nova-blue-subql-node-config.deployment-color}-${var.nova-blue-subql-node-config.network-name} >> /home/${var.ssh_user}/astral/.env",
Expand All @@ -169,6 +169,15 @@ resource "null_resource" "start-nova-blue-subql-nodes" {
"grep -q '^HASURA_GRAPHQL_ADMIN_SECRET=' /home/${var.ssh_user}/astral/.env && sed -i 's/^HASURA_GRAPHQL_ADMIN_SECRET=.*/HASURA_GRAPHQL_ADMIN_SECRET=${var.hasura_graphql_admin_secret}/' /home/${var.ssh_user}/astral/.env || echo HASURA_GRAPHQL_ADMIN_SECRET=${var.hasura_graphql_admin_secret} >> /home/${var.ssh_user}/astral/.env",
"grep -q '^HASURA_GRAPHQL_JWT_SECRET=' /home/${var.ssh_user}/astral/.env && sed -i 's|^HASURA_GRAPHQL_JWT_SECRET=.*|HASURA_GRAPHQL_JWT_SECRET={\"type\":\"HS256\",\"key\":\"${var.hasura_graphql_jwt_secret}\"}|' /home/${var.ssh_user}/astral/.env || echo HASURA_GRAPHQL_JWT_SECRET={\"type\":\"HS256\",\"key\":\"${var.hasura_graphql_jwt_secret}\"} >> /home/${var.ssh_user}/astral/.env",

# run subql stack
"chmod +x /home/${var.ssh_user}/subql/install_subql_stack.sh",
"bash /home/${var.ssh_user}/subql/install_subql_stack.sh",
"export $(grep -v '^#' /home/${var.ssh_user}/astral/.env | xargs)",
"cd /home/${var.ssh_user}/astral/indexers",
"yarn build-dictionary",
"npx lerna run codegen",
"npx lerna run build",
"sudo docker compose -p prod-astral-indexers -f /home/${var.ssh_user}/astral/docker-compose.yml -f /home/${var.ssh_user}/astral/docker-compose.prod.yml --profile dictionary --profile task --profile taurus up -d --remove-orphans",
"echo 'Installation Complete'",
]
}
Expand Down Expand Up @@ -225,7 +234,6 @@ resource "null_resource" "nova-start-green-subql-nodes" {
# run subql install script
"chmod +x /home/${var.ssh_user}/subql/install_subql_stack.sh",
"bash /home/${var.ssh_user}/subql/install_subql_stack.sh",
"echo 'Installation Complete'",

# create .env file
"grep -q '^NR_AGENT_IDENTIFIER=' /home/${var.ssh_user}/astral/.env && sed -i 's/^NR_AGENT_IDENTIFIER=.*/NR_AGENT_IDENTIFIER=subql-${var.nova-green-subql-node-config.deployment-color}-${var.nova-green-subql-node-config.network-name}/' /home/${var.ssh_user}/astral/.env || echo NR_AGENT_IDENTIFIER=subql-${var.nova-green-subql-node-config.deployment-color}-${var.nova-green-subql-node-config.network-name} >> /home/${var.ssh_user}/astral/.env",
Expand All @@ -235,6 +243,15 @@ resource "null_resource" "nova-start-green-subql-nodes" {
"grep -q '^HASURA_GRAPHQL_ADMIN_SECRET=' /home/${var.ssh_user}/astral/.env && sed -i 's/^HASURA_GRAPHQL_ADMIN_SECRET=.*/HASURA_GRAPHQL_ADMIN_SECRET=${var.hasura_graphql_admin_secret}/' /home/${var.ssh_user}/astral/.env || echo HASURA_GRAPHQL_ADMIN_SECRET=${var.hasura_graphql_admin_secret} >> /home/${var.ssh_user}/astral/.env",
"grep -q '^HASURA_GRAPHQL_JWT_SECRET=' /home/${var.ssh_user}/astral/.env && sed -i 's|^HASURA_GRAPHQL_JWT_SECRET=.*|HASURA_GRAPHQL_JWT_SECRET={\"type\":\"HS256\",\"key\":\"${var.hasura_graphql_jwt_secret}\"}|' /home/${var.ssh_user}/astral/.env || echo HASURA_GRAPHQL_JWT_SECRET={\"type\":\"HS256\",\"key\":\"${var.hasura_graphql_jwt_secret}\"} >> /home/${var.ssh_user}/astral/.env",

# run subql stack
"chmod +x /home/${var.ssh_user}/subql/install_subql_stack.sh",
"bash /home/${var.ssh_user}/subql/install_subql_stack.sh",
"export $(grep -v '^#' /home/${var.ssh_user}/astral/.env | xargs)",
"cd /home/${var.ssh_user}/astral/indexers",
"yarn build-dictionary",
"npx lerna run codegen",
"npx lerna run build",
"sudo docker compose -p prod-astral-indexers -f /home/${var.ssh_user}/astral/docker-compose.yml -f /home/${var.ssh_user}/astral/docker-compose.prod.yml --profile dictionary --profile task --profile taurus up -d --remove-orphans",
"echo 'Installation Complete'",
]
}
Expand Down
31 changes: 22 additions & 9 deletions templates/terraform/subql/base/bootstrap_subql_provisioner.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ resource "null_resource" "setup-green-subql-nodes" {
# create subql dir
provisioner "remote-exec" {
inline = [
"mkdir -p /home/${var.ssh_user}/subql",
"mkdir -p /home/${var.ssh_user}/subql/postgresql",
"mkdir -p /home/${var.ssh_user}/subql/postgresql/{conf,data}",
"sudo mkdir -p /home/${var.ssh_user}/subql",
"sudo mkdir -p /home/${var.ssh_user}/subql/postgresql",
"sudo mkdir -p /home/${var.ssh_user}/subql/postgresql/conf",
"sudo mkdir -p /home/${var.ssh_user}/subql/postgresql/data",
"sudo chown -R ${var.ssh_user}:${var.ssh_user} /home/${var.ssh_user}/subql/ && sudo chmod -R 750 /home/${var.ssh_user}/subql/"
]
}
Expand Down Expand Up @@ -156,11 +157,6 @@ resource "null_resource" "start-blue-subql-nodes" {
# set hostname
"sudo hostnamectl set-hostname subql-${var.blue-subql-node-config.deployment-color}-${var.blue-subql-node-config.network-name}",

# run subql install script
"chmod +x /home/${var.ssh_user}/subql/install_subql_stack.sh",
"bash /home/${var.ssh_user}/subql/install_subql_stack.sh",
"echo 'Installation Complete'",

# create .env file
"grep -q '^NR_AGENT_IDENTIFIER=' /home/${var.ssh_user}/astral/.env && sed -i 's/^NR_AGENT_IDENTIFIER=.*/NR_AGENT_IDENTIFIER=subql-${var.blue-subql-node-config.deployment-color}-${var.blue-subql-node-config.network-name}/' /home/${var.ssh_user}/astral/.env || echo NR_AGENT_IDENTIFIER=subql-${var.blue-subql-node-config.deployment-color}-${var.blue-subql-node-config.network-name} >> /home/${var.ssh_user}/astral/.env",
"grep -q '^NR_API_KEY=' /home/${var.ssh_user}/astral/.env && sed -i 's/^NR_API_KEY=.*/NR_API_KEY=${var.nr_api_key}/' /home/${var.ssh_user}/astral/.env || echo NR_API_KEY=${var.nr_api_key} >> /home/${var.ssh_user}/astral/.env",
Expand All @@ -169,6 +165,15 @@ resource "null_resource" "start-blue-subql-nodes" {
"grep -q '^HASURA_GRAPHQL_ADMIN_SECRET=' /home/${var.ssh_user}/astral/.env && sed -i 's/^HASURA_GRAPHQL_ADMIN_SECRET=.*/HASURA_GRAPHQL_ADMIN_SECRET=${var.hasura_graphql_admin_secret}/' /home/${var.ssh_user}/astral/.env || echo HASURA_GRAPHQL_ADMIN_SECRET=${var.hasura_graphql_admin_secret} >> /home/${var.ssh_user}/astral/.env",
"grep -q '^HASURA_GRAPHQL_JWT_SECRET=' /home/${var.ssh_user}/astral/.env && sed -i 's|^HASURA_GRAPHQL_JWT_SECRET=.*|HASURA_GRAPHQL_JWT_SECRET={\"type\":\"HS256\",\"key\":\"${var.hasura_graphql_jwt_secret}\"}|' /home/${var.ssh_user}/astral/.env || echo HASURA_GRAPHQL_JWT_SECRET={\"type\":\"HS256\",\"key\":\"${var.hasura_graphql_jwt_secret}\"} >> /home/${var.ssh_user}/astral/.env",

# run subql stack
"chmod +x /home/${var.ssh_user}/subql/install_subql_stack.sh",
"bash /home/${var.ssh_user}/subql/install_subql_stack.sh",
"export $(grep -v '^#' /home/${var.ssh_user}/astral/.env | xargs)",
"cd /home/${var.ssh_user}/astral/indexers",
"yarn build-dictionary",
"npx lerna run codegen",
"npx lerna run build",
"sudo docker compose -p prod-astral-indexers -f /home/${var.ssh_user}/astral/docker-compose.yml -f /home/${var.ssh_user}/astral/docker-compose.prod.yml --profile dictionary --profile task --profile taurus up -d --remove-orphans",
"echo 'Installation Complete'",
]
}
Expand Down Expand Up @@ -225,7 +230,6 @@ resource "null_resource" "start-green-subql-nodes" {
# run subql install script
"chmod +x /home/${var.ssh_user}/subql/install_subql_stack.sh",
"bash /home/${var.ssh_user}/subql/install_subql_stack.sh",
"echo 'Installation Complete'",

# create .env file
"grep -q '^NR_AGENT_IDENTIFIER=' /home/${var.ssh_user}/astral/.env && sed -i 's/^NR_AGENT_IDENTIFIER=.*/NR_AGENT_IDENTIFIER=subql-${var.green-subql-node-config.deployment-color}-${var.green-subql-node-config.network-name}/' /home/${var.ssh_user}/astral/.env || echo NR_AGENT_IDENTIFIER=subql-${var.green-subql-node-config.deployment-color}-${var.green-subql-node-config.network-name} >> /home/${var.ssh_user}/astral/.env",
Expand All @@ -235,6 +239,15 @@ resource "null_resource" "start-green-subql-nodes" {
"grep -q '^HASURA_GRAPHQL_ADMIN_SECRET=' /home/${var.ssh_user}/astral/.env && sed -i 's/^HASURA_GRAPHQL_ADMIN_SECRET=.*/HASURA_GRAPHQL_ADMIN_SECRET=${var.hasura_graphql_admin_secret}/' /home/${var.ssh_user}/astral/.env || echo HASURA_GRAPHQL_ADMIN_SECRET=${var.hasura_graphql_admin_secret} >> /home/${var.ssh_user}/astral/.env",
"grep -q '^HASURA_GRAPHQL_JWT_SECRET=' /home/${var.ssh_user}/astral/.env && sed -i 's|^HASURA_GRAPHQL_JWT_SECRET=.*|HASURA_GRAPHQL_JWT_SECRET={\"type\":\"HS256\",\"key\":\"${var.hasura_graphql_jwt_secret}\"}|' /home/${var.ssh_user}/astral/.env || echo HASURA_GRAPHQL_JWT_SECRET={\"type\":\"HS256\",\"key\":\"${var.hasura_graphql_jwt_secret}\"} >> /home/${var.ssh_user}/astral/.env",

# run subql stack
"chmod +x /home/${var.ssh_user}/subql/install_subql_stack.sh",
"bash /home/${var.ssh_user}/subql/install_subql_stack.sh",
"export $(grep -v '^#' /home/${var.ssh_user}/astral/.env | xargs)",
"cd /home/${var.ssh_user}/astral/indexers",
"yarn build-dictionary",
"npx lerna run codegen",
"npx lerna run build",
"sudo docker compose -p prod-astral-indexers -f /home/${var.ssh_user}/astral/docker-compose.yml -f /home/${var.ssh_user}/astral/docker-compose.prod.yml --profile dictionary --profile task --profile taurus up -d --remove-orphans",
"echo 'Installation Complete'",
]
}
Expand Down
12 changes: 0 additions & 12 deletions templates/terraform/subql/base/scripts/install_subql_stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,3 @@ git clone https://github.com/autonomys/astral.git
cd astral/indexers

yarn install --frozen-lockfile

export $(grep -v '^#' ../.env | xargs) &&
yarn build-dictionary &&
npx lerna run codegen &&
npx lerna run build &&
sudo docker compose -p prod-astral-indexers \
-f ../docker-compose.yml \
-f ../docker-compose.prod.yml \
--profile dictionary \
--profile task \
--profile taurus \
up -d --remove-orphans

0 comments on commit 39cad35

Please sign in to comment.