forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen.validators.sh
executable file
·132 lines (112 loc) · 2.93 KB
/
gen.validators.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
# Copyright (c) Mysten Labs, Inc.
# SPDX-License-Identifier: Apache-2.0
set -e
# number of primary instances to start.
num_primary=$1
# number of worker instances per primary to start.
num_worker=$2
if [ -z "${num_primary}" ]; then
echo usage: $0 number_of_instances
exit 1
fi
if [ ! -x ../target/release/node ]; then
echo no narwhal node command found.
exit 1
fi
node=../target/release/node
target=validators-${num_primary}
mkdir -p $target
./scripts/gen.compose.py -np ${num_primary} -t templates/node.template > ${target}/docker-compose.yaml
# loki config
cat > ${target}/loki-config.yaml <<EOF
---
server:
http_listen_port: 3100
memberlist:
join_members:
- loki:7946
schema_config:
configs:
- from: 2021-08-01
store: boltdb-shipper
object_store: s3
schema: v11
index:
prefix: index_
period: 24h
common:
path_prefix: /loki
replication_factor: 1
storage:
s3:
endpoint: minio:9000
insecure: true
bucketnames: "loki-data"
access_key_id: loki
secret_access_key: supersecret
s3forcepathstyle: true
ring:
kvstore:
store: memberlist
ruler:
storage:
s3:
bucketnames: loki-ruler
EOF
cat > ${target}/promtail-local-config.yaml <<EOF
---
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://gateway:3100/loki/api/v1/push
tenant_id: tenant1
scrape_configs:
- job_name: docker_log_scrape
docker_sd_configs:
- host: unix:///var/run/docker.sock
refresh_interval: 5s
relabel_configs:
- source_labels: ['__meta_docker_container_name']
regex: '/(.*)'
target_label: 'container'
- job_name: validators
static_configs:
- targets:
- localhost
labels:
job: servicelogs
__path__: /validators/validator-*/logs/log-*.txt
EOF
t=$(($num_primary - 1))
for i in $(seq -f %02g 0 ${t})
do
val=${target}/validator-${i}
mkdir -p ${val}/{db-primary,db-worker-0,logs}
${node} generate_keys --filename ${val}/key.json
${node} generate_network_keys --filename ${val}/network-key.json
done
cp validators/parameters.json ${target}/parameters.json
./scripts/gen.committee.py -n ${num_primary} -d ${target} > ${target}/committee.json
./scripts/gen.workers.py -np ${num_primary} -nw ${num_worker} -d ${target} > ${target}/workers.json
cp -r templates/{grafana,prometheus} ${target}/
# add the primary and worker nodes to the prometheus.yaml scrape configs.
t=$(($num_primary - 1))
for i in $(seq -f %02g 0 ${t})
do
scrape_primary="primary_${i}:8010"
scrape_worker="worker_${i}:8010"
cat >> ${target}/prometheus/prometheus.yml <<EOF
- job_name: 'primary_${i}'
scrape_interval: 10s
static_configs:
- targets: ['${scrape_primary}']
- job_name: 'worker_${i}'
scrape_interval: 10s
static_configs:
- targets: ['${scrape_worker}']
EOF
done