Skip to content

Commit 134aa8f

Browse files
committed
subql changes
1 parent caedbca commit 134aa8f

File tree

11 files changed

+78
-219
lines changed

11 files changed

+78
-219
lines changed

explorer/terraform/aws/taurus/main.tf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module "subql" {
1515
instance-count-blue = var.instance_count_blue
1616
disk-volume-size = var.disk_volume_size
1717
disk-volume-type = var.disk_volume_type
18-
prune = false
1918
environment = "production"
2019
}
2120

@@ -30,37 +29,34 @@ module "subql" {
3029
instance-count-green = var.instance_count_green
3130
disk-volume-size = var.disk_volume_size
3231
disk-volume-type = var.disk_volume_type
33-
prune = false
3432
environment = "staging"
3533
}
3634

3735
nova-blue-subql-node-config = {
3836
deployment-color = "blue"
3937
network-name = "${var.network_name}"
40-
domain-prefix = "nova.blue"
38+
domain-prefix = "nova.subql.blue"
4139
docker-tag = "evm-domain"
4240
instance-type = var.instance_type
4341
deployment-version = 0
4442
regions = var.aws_region
4543
instance-count-blue = var.instance_count_blue
4644
disk-volume-size = var.disk_volume_size
4745
disk-volume-type = var.disk_volume_type
48-
prune = false
4946
environment = "production"
5047
}
5148

5249
nova-green-subql-node-config = {
5350
deployment-color = "green"
5451
network-name = "${var.network_name}"
55-
domain-prefix = "nova.green"
52+
domain-prefix = "nova.subql.green"
5653
docker-tag = "evm-domain"
5754
instance-type = var.instance_type
5855
deployment-version = 0
5956
regions = var.aws_region
6057
instance-count-green = 0 #var.instance_count_green
6158
disk-volume-size = var.disk_volume_size
6259
disk-volume-type = var.disk_volume_type
63-
prune = false
6460
environment = "staging"
6561
}
6662

@@ -75,6 +71,5 @@ module "subql" {
7571
vpc_cidr_block = var.vpc_cidr_block
7672
public_subnet_cidrs = var.public_subnet_cidrs
7773
postgres_password = var.postgres_password
78-
prometheus_secret = var.prometheus_secret
7974
hasura_graphql_admin_secret = var.hasura_graphql_admin_secret
8075
}

explorer/terraform/aws/taurus/terraform.tfvars.example

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,5 @@ private_key_path = ""
1616
cloudflare_email = ""
1717
cloudflare_api_token = ""
1818
nr_api_key = ""
19-
netdata_token = ""
2019
postgres_password = ""
21-
prometheus_secret = ""
2220
hasura_graphql_admin_secret = ""

explorer/terraform/aws/taurus/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
variable "netdata_token" {
2-
type = string
3-
sensitive = true
4-
5-
}
6-
71
variable "node_tag" {
82
type = string
93
}

templates/terraform/subql/base/bootstrap_subql_provisioner.tf

Lines changed: 27 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ resource "null_resource" "setup-blue-subql-nodes" {
5050
destination = "/home/${var.ssh_user}/subql/postgresql/conf/postgresql.conf"
5151
}
5252

53-
# copy compose file creation script
53+
# copy subql launch script
5454
provisioner "file" {
55-
source = "${var.path_to_scripts}/create_subql_node_compose_file.sh"
56-
destination = "/home/${var.ssh_user}/subql/create_compose_file.sh"
55+
source = "${var.path_to_scripts}/install_subql_stack.sh"
56+
destination = "/home/${var.ssh_user}/subql/subql_stack.sh"
5757
}
5858

5959
# copy docker install file
@@ -120,15 +120,10 @@ resource "null_resource" "setup-green-subql-nodes" {
120120
destination = "/home/${var.ssh_user}/subql/postgresql/conf/postgresql.conf"
121121
}
122122

123-
# copy compose file creation script
123+
# copy subql launch script
124124
provisioner "file" {
125-
source = "${var.path_to_scripts}/create_subql_node_compose_file.sh"
126-
destination = "/home/${var.ssh_user}/subql/create_compose_file.sh"
127-
}
128-
129-
provisioner "file" {
130-
source = "${var.path_to_scripts}/set_env_vars.sh"
131-
destination = "/home/${var.ssh_user}/subql/set_env_vars.sh"
125+
source = "${var.path_to_scripts}/install_subql_stack.sh"
126+
destination = "/home/${var.ssh_user}/subql/subql_stack.sh"
132127
}
133128

134129
# copy docker install file
@@ -155,63 +150,6 @@ resource "null_resource" "setup-green-subql-nodes" {
155150

156151
}
157152

158-
159-
resource "null_resource" "prune-blue-subql-nodes" {
160-
count = var.blue-subql-node-config.prune ? length(local.blue_subql_node_ip_v4) : 0
161-
depends_on = [null_resource.setup-blue-subql-nodes]
162-
163-
triggers = {
164-
prune = var.blue-subql-node-config.prune
165-
}
166-
167-
connection {
168-
host = local.blue_subql_node_ip_v4[count.index]
169-
user = var.ssh_user
170-
type = "ssh"
171-
agent = true
172-
agent_identity = var.aws_key_name
173-
private_key = file("${var.private_key_path}")
174-
timeout = "300s"
175-
}
176-
177-
# prune network
178-
provisioner "remote-exec" {
179-
inline = [
180-
"sudo docker ps -aq | xargs docker stop",
181-
"sudo docker system prune -a -f && docker volume ls -q | xargs docker volume rm -f",
182-
"cat /dev/null > $HOME/.bash_profile"
183-
]
184-
}
185-
}
186-
187-
resource "null_resource" "prune-green-subql-nodes" {
188-
count = var.green-subql-node-config.prune ? length(local.green_subql_node_ip_v4) : 0
189-
depends_on = [null_resource.setup-green-subql-nodes]
190-
191-
triggers = {
192-
prune = var.green-subql-node-config.prune
193-
}
194-
195-
connection {
196-
host = local.green_subql_node_ip_v4[count.index]
197-
user = var.ssh_user
198-
type = "ssh"
199-
agent = true
200-
agent_identity = var.aws_key_name
201-
private_key = file("${var.private_key_path}")
202-
timeout = "300s"
203-
}
204-
205-
# prune network
206-
provisioner "remote-exec" {
207-
inline = [
208-
"sudo docker ps -aq | xargs sudo docker stop",
209-
"sudo docker system prune -a -f && sudo docker volume ls -q | xargs sudo docker volume rm -f",
210-
"cat /dev/null > $HOME/.bash_profile",
211-
]
212-
}
213-
}
214-
215153
resource "null_resource" "start-blue-subql-nodes" {
216154
count = length(local.blue_subql_node_ip_v4)
217155

@@ -239,6 +177,9 @@ resource "null_resource" "start-blue-subql-nodes" {
239177
# install nginx, certbot, docker and docker compose
240178
"chmod +x /home/${var.ssh_user}/subql/install_docker.sh",
241179
"sudo bash /home/${var.ssh_user}/subql/install_docker.sh",
180+
# start docker daemon
181+
"sudo systemctl enable --now docker.service",
182+
"sudo systemctl restart docker.service",
242183
# copy files
243184
"sudo cp -f /home/${var.ssh_user}/subql/cors-settings.conf /etc/nginx/cors-settings.conf",
244185
"sudo cp -f /home/${var.ssh_user}/subql/backend.conf /etc/nginx/backend.conf",
@@ -250,47 +191,20 @@ resource "null_resource" "start-blue-subql-nodes" {
250191
"sudo systemctl enable nginx",
251192
"sudo systemctl start nginx",
252193
# install certbot & generate domain
253-
"sudo certbot --nginx --non-interactive -v --agree-tos -m [email protected] -d subql.${var.network_name}.subspace.network -d ${var.blue-subql-node-config.domain-prefix}.subql.${var.network_name}.subspace.network",
194+
"sudo certbot --nginx --non-interactive -v --agree-tos -m [email protected] -d ${var.blue-subql-node-config.domain-prefix}.${var.network_name}.subspace.network",
254195
"sudo systemctl restart nginx",
255-
# install netdata
256-
"sudo sh -c \"curl https://my-netdata.io/kickstart.sh > /tmp/netdata-kickstart.sh && sh /tmp/netdata-kickstart.sh --non-interactive --nightly-channel --claim-token ${var.netdata_token} --claim-url https://app.netdata.cloud\"",
257196
# set hostname
258197
"sudo hostnamectl set-hostname subql-${var.blue-subql-node-config.network-name}",
259198

260199
# create .env file
261-
"echo NETWORK_NAME=${var.network_name} >> /home/${var.ssh_user}/subql/.env",
262-
"echo DOMAIN_PREFIX=${var.blue-subql-node-config.domain-prefix} >> /home/${var.ssh_user}/subql/.env",
263200
"echo NR_API_KEY=${var.nr_api_key} >> /home/${var.ssh_user}/subql/.env",
264201
"echo DOCKER_TAG=${var.blue-subql-node-config.docker-tag} >> /home/${var.ssh_user}/subql/.env",
265-
"echo NODE_NAME=SUBsubql_GEMINI_3h >> /home/${var.ssh_user}/subql/.env",
266-
"echo POSTGRES_HOST=db >> /home/${var.ssh_user}/subql/.env",
267-
"echo POSTGRES_PORT=5432 >> /home/${var.ssh_user}/subql/.env",
268-
"echo POSTGRES_USER=postgres >> /home/${var.ssh_user}/subql/.env",
269-
"echo POSTGRES_DB=subql-archive >> /home/${var.ssh_user}/subql/.env",
270202
"echo POSTGRES_PASSWORD=${var.postgres_password} >> /home/${var.ssh_user}/subql/.env",
271-
"echo DB_TYPE=postgres >> /home/${var.ssh_user}/subql/.env",
272-
"echo DB_HOST=db >> /home/${var.ssh_user}/subql/.env",
273-
"echo DB_PORT=5432 >> /home/${var.ssh_user}/subql/.env",
274-
"echo DB_USER=postgres >> /home/${var.ssh_user}/subql/.env",
275-
"echo DB_NAME=subql-archive >> /home/${var.ssh_user}/subql/.env",
276-
"echo DB_PASS=${var.postgres_password} >> /home/${var.ssh_user}/subql/.env",
277-
"echo ARCHIVE_ENDPOINT=https://archive.gemini-3h.subspace.network/api >> /home/${var.ssh_user}/subql/.env",
278-
"echo CHAIN_RPC_ENDPOINT=wss://rpc-0.gemini-3h.subspace.network/ws >> /home/${var.ssh_user}/subql/.env",
279-
"echo PROCESSOR_HEALTH_HOST=http://processor:3000 >> /home/${var.ssh_user}/subql/.env",
280-
"echo PROCESSOR_HEALTH_PORT=7070 >> /home/${var.ssh_user}/subql/.env",
281-
"echo HEALTH_CHECK_PORT=8080 >> /home/${var.ssh_user}/subql/.env",
282-
"echo INGEST_HEALTH_HOST=http://ingest:9090 >> /home/${var.ssh_user}/subql/.env",
283-
"echo INGEST_HEALTH_PORT=7070 >> /home/${var.ssh_user}/subql/.env",
284-
"echo MY_SECRET=${var.prometheus_secret} >> /home/${var.ssh_user}/subql/.env",
285203
"echo HASURA_GRAPHQL_ADMIN_SECRET=${var.hasura_graphql_admin_secret} >> /home/${var.ssh_user}/subql/.env",
286204

287-
# create docker compose file
288-
"chmod +x /home/${var.ssh_user}/subql/create_compose_file.sh",
289-
"bash /home/${var.ssh_user}/subql/create_compose_file.sh",
290-
# start docker daemon
291-
"sudo systemctl enable --now docker.service",
292-
"sudo systemctl restart docker.service",
293-
"sudo docker compose -f ./subql/docker-compose.yml up -d",
205+
# run subql lauch script
206+
"chmod +x /home/${var.ssh_user}/subql/subql_stack.sh",
207+
"bash /home/${var.ssh_user}/subql/subql_stack.sh",
294208
"echo 'Installation Complete'",
295209
]
296210
}
@@ -333,6 +247,12 @@ resource "null_resource" "start-green-subql-nodes" {
333247
# install deployments
334248
provisioner "remote-exec" {
335249
inline = [
250+
# install nginx, certbot, docker and docker compose
251+
"chmod +x /home/${var.ssh_user}/subql/install_docker.sh",
252+
"sudo bash /home/${var.ssh_user}/subql/install_docker.sh",
253+
# start docker daemon
254+
"sudo systemctl enable --now docker.service",
255+
"sudo systemctl restart docker.service",
336256
# copy files
337257
"sudo cp -f /home/${var.ssh_user}/subql/cors-settings.conf /etc/nginx/cors-settings.conf",
338258
"sudo cp -f /home/${var.ssh_user}/subql/backend.conf /etc/nginx/backend.conf",
@@ -344,44 +264,20 @@ resource "null_resource" "start-green-subql-nodes" {
344264
"sudo systemctl enable nginx",
345265
"sudo systemctl start nginx",
346266
# install certbot & generate domain
347-
"sudo certbot --nginx --non-interactive -v --agree-tos -m [email protected] -d subql.${var.network_name}.subspace.network -d ${var.green-subql-node-config.domain-prefix}.${var.network_name}.subspace.network",
267+
"sudo certbot --nginx --non-interactive -v --agree-tos -m [email protected] -d subql.${var.network_name}.subspace.network -d ${var.blue-subql-node-config.domain-prefix}.subql.${var.network_name}.subspace.network",
348268
"sudo systemctl restart nginx",
349269
# set hostname
350-
"sudo hostnamectl set-hostname subql-${var.green-subql-node-config.network-name}",
270+
"sudo hostnamectl set-hostname subql-${var.blue-subql-node-config.network-name}",
271+
351272
# create .env file
352-
"echo NETWORK_NAME=${var.network_name} >> /home/${var.ssh_user}/subql/.env",
353-
"echo DOMAIN_PREFIX=${var.green-subql-node-config.domain-prefix} >> /home/${var.ssh_user}/subql/.env",
354273
"echo NR_API_KEY=${var.nr_api_key} >> /home/${var.ssh_user}/subql/.env",
355-
"echo DOCKER_TAG=${var.green-subql-node-config.docker-tag} >> /home/${var.ssh_user}/subql/.env",
356-
"echo NODE_NAME=SUBsubql_GEMINI_3h >> /home/${var.ssh_user}/subql/.env",
357-
"echo POSTGRES_HOST=db >> /home/${var.ssh_user}/subql/.env",
358-
"echo POSTGRES_PORT=5432 >> /home/${var.ssh_user}/subql/.env",
359-
"echo POSTGRES_USER=postgres >> /home/${var.ssh_user}/subql/.env",
360-
"echo POSTGRES_DB=subql-archive >> /home/${var.ssh_user}/subql/.env",
274+
"echo DOCKER_TAG=${var.blue-subql-node-config.docker-tag} >> /home/${var.ssh_user}/subql/.env",
361275
"echo POSTGRES_PASSWORD=${var.postgres_password} >> /home/${var.ssh_user}/subql/.env",
362-
"echo DB_TYPE=postgres >> /home/${var.ssh_user}/subql/.env",
363-
"echo DB_HOST=db >> /home/${var.ssh_user}/subql/.env",
364-
"echo DB_PORT=5432 >> /home/${var.ssh_user}/subql/.env",
365-
"echo DB_USER=postgres >> /home/${var.ssh_user}/subql/.env",
366-
"echo DB_NAME=subql-archive >> /home/${var.ssh_user}/subql/.env",
367-
"echo DB_PASS=${var.postgres_password} >> /home/${var.ssh_user}/subql/.env",
368-
"echo ARCHIVE_ENDPOINT=https://archive.gemini-3h.subspace.network/api >> /home/${var.ssh_user}/subql/.env",
369-
"echo CHAIN_RPC_ENDPOINT=wss://rpc-0.gemini-3h.subspace.network/ws >> /home/${var.ssh_user}/subql/.env",
370-
"echo PROCESSOR_HEALTH_HOST=http://processor:3000 >> /home/${var.ssh_user}/subql/.env",
371-
"echo PROCESSOR_HEALTH_PORT=7070 >> /home/${var.ssh_user}/subql/.env",
372-
"echo HEALTH_CHECK_PORT=8080 >> /home/${var.ssh_user}/subql/.env",
373-
"echo INGEST_HEALTH_HOST=http://ingest:9090 >> /home/${var.ssh_user}/subql/.env",
374-
"echo INGEST_HEALTH_PORT=7070 >> /home/${var.ssh_user}/subql/.env",
375-
"echo MY_SECRET=${var.prometheus_secret} >> /home/${var.ssh_user}/subql/.env",
376-
377-
# create docker compose file
378-
"chmod +x /home/${var.ssh_user}/subql/create_compose_file.sh",
379-
"bash /home/${var.ssh_user}/subql/create_compose_file.sh",
276+
"echo HASURA_GRAPHQL_ADMIN_SECRET=${var.hasura_graphql_admin_secret} >> /home/${var.ssh_user}/subql/.env",
380277

381-
# start docker daemon
382-
"sudo systemctl enable --now docker.service",
383-
"sudo systemctl restart docker.service",
384-
"sudo docker compose -f ./subql/docker-compose.yml up -d",
278+
# run subql lauch script
279+
"chmod +x /home/${var.ssh_user}/subql/subql_stack.sh",
280+
"bash /home/${var.ssh_user}/subql/subql_stack.sh",
385281
"echo 'Installation Complete'",
386282
]
387283
}

templates/terraform/subql/base/common.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
variable "netdata_token" {
2-
type = string
3-
sensitive = true
4-
5-
}
6-
71
variable "nr_api_key" {
82
description = "New relic API Key"
93
type = string

templates/terraform/subql/base/config/nginx-subql.conf

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,4 @@ server {
2121
proxy_http_version 1.1;
2222
}
2323

24-
location /db-health {
25-
proxy_buffering off;
26-
proxy_pass http://127.0.0.1:8080/health;
27-
proxy_set_header X-Real-IP $remote_addr;
28-
proxy_set_header Host $host;
29-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
30-
proxy_http_version 1.1;
31-
}
32-
33-
location /processor-health {
34-
proxy_buffering off;
35-
proxy_pass http://127.0.0.1:7070/health;
36-
proxy_set_header X-Real-IP $remote_addr;
37-
proxy_set_header Host $host;
38-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
39-
proxy_http_version 1.1;
40-
}
4124
}

templates/terraform/subql/base/dns.tf

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ resource "cloudflare_record" "subql-live" {
3232
resource "cloudflare_record" "nova-subql-blue" {
3333
count = var.nova-blue-subql-node-config.instance-count-blue > 0 ? var.nova-blue-subql-node-config.instance-count-blue : 0
3434
zone_id = data.cloudflare_zone.cloudflare_zone.id
35-
name = "${var.nova-blue-subql-node-config.domain-prefix}.subql.${var.network_name}"
35+
name = "${var.nova-blue-subql-node-config.domain-prefix}.${var.network_name}"
3636
value = local.nova_blue_subql_node_ip_v4[count.index]
3737
type = "A"
3838
ttl = "3600"
@@ -41,7 +41,7 @@ resource "cloudflare_record" "nova-subql-blue" {
4141
resource "cloudflare_record" "nova-subql-green" {
4242
count = var.nova-green-subql-node-config.instance-count-green > 0 ? var.nova-green-subql-node-config.instance-count-green : 0
4343
zone_id = data.cloudflare_zone.cloudflare_zone.id
44-
name = "${var.nova-green-subql-node-config.domain-prefix}.subql.${var.network_name}"
44+
name = "${var.nova-green-subql-node-config.domain-prefix}.${var.network_name}"
4545
value = local.nova_green_subql_node_ip_v4[count.index]
4646
type = "A"
4747
ttl = "3600"
@@ -55,30 +55,3 @@ resource "cloudflare_record" "nova-subql-live" {
5555
type = "A"
5656
ttl = "3600"
5757
}
58-
59-
resource "cloudflare_record" "nova" {
60-
count = var.nova-blockscout-node-config.instance-count > 0 ? var.nova-blockscout-node-config.instance-count : 0
61-
zone_id = data.cloudflare_zone.cloudflare_zone.id
62-
name = "${var.nova-blockscout-node-config.domain-prefix}.${var.network_name}"
63-
value = local.blockscout_node_ip_v4[count.index]
64-
type = "A"
65-
ttl = "3600"
66-
}
67-
68-
resource "cloudflare_record" "archive" {
69-
count = var.archive-node-config.instance-count > 0 ? var.archive-node-config.instance-count : 0
70-
zone_id = data.cloudflare_zone.cloudflare_zone.id
71-
name = "${var.archive-node-config.domain-prefix}.${var.network_name}"
72-
value = local.archive_node_ip_v4[count.index]
73-
type = "A"
74-
ttl = "3600"
75-
}
76-
77-
resource "cloudflare_record" "nova-archive" {
78-
count = var.nova-archive-node-config.instance-count > 0 ? var.nova-archive-node-config.instance-count : 0
79-
zone_id = data.cloudflare_zone.cloudflare_zone.id
80-
name = "${var.nova-archive-node-config.domain-prefix}.${var.network_name}"
81-
value = local.nova_archive_node_ip_v4[count.index]
82-
type = "A"
83-
ttl = "3600"
84-
}

0 commit comments

Comments
 (0)