Bootstrap config upgrade
- only IPVS for access, no docker's portforwarding - generate random password - generate config for collectd's curl_json
This commit is contained in:
parent
d4c6db4997
commit
17d1e901c0
|
@ -4,7 +4,6 @@ services:
|
||||||
bootstrap:
|
bootstrap:
|
||||||
image: pybitmessage/bootstrap:latest
|
image: pybitmessage/bootstrap:latest
|
||||||
build: ..
|
build: ..
|
||||||
ports:
|
env_file: .env
|
||||||
- 127.0.0.1::8444
|
|
||||||
deploy:
|
deploy:
|
||||||
replicas: $THREADS
|
replicas: $THREADS
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
apt -y install curl jq ipvsadm
|
apt -y install curl jq ipvsadm libyajl2
|
||||||
|
|
||||||
EXTIP=$(curl -s telnetmyip.com|jq -r .ip)
|
EXTIP=$(curl -s telnetmyip.com|jq -r .ip)
|
||||||
|
if [ ! -e .env ]; then
|
||||||
THREADS=$(nproc --all)
|
THREADS=$(nproc --all)
|
||||||
echo "THREADS=$THREADS" > .env
|
PASSWORD=$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo)
|
||||||
|
cat > .env << EOF
|
||||||
|
THREADS=$THREADS
|
||||||
|
USER=pybitmessage
|
||||||
|
PASSWORD=$PASSWORD
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
. .env
|
||||||
|
fi
|
||||||
|
|
||||||
ipvsadm -C
|
ipvsadm -C
|
||||||
ipvsadm -A -t ${EXTIP}:8444 -s rr
|
ipvsadm -A -t ${EXTIP}:8444 -s rr
|
||||||
|
@ -12,6 +21,11 @@ ipvsadm -A -t ${EXTIP}:8080 -s rr
|
||||||
|
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
|
CF=/etc/collectd/collectd.conf.d/curl_json.conf
|
||||||
|
|
||||||
|
echo "LoadPlugin curl_json" > $CF
|
||||||
|
echo "<Plugin curl_json>" >> $CF
|
||||||
|
|
||||||
for i in `seq 1 $THREADS`; do
|
for i in `seq 1 $THREADS`; do
|
||||||
cont="pybitmessage-bootstrap-${i}"
|
cont="pybitmessage-bootstrap-${i}"
|
||||||
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $cont 2>/dev/null)
|
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $cont 2>/dev/null)
|
||||||
|
@ -19,6 +33,34 @@ for i in `seq 1 $THREADS`; do
|
||||||
echo "Adding $IP"
|
echo "Adding $IP"
|
||||||
ipvsadm -a -t ${EXTIP}:8444 -r ${IP}:8444 -m
|
ipvsadm -a -t ${EXTIP}:8444 -r ${IP}:8444 -m
|
||||||
ipvsadm -a -t ${EXTIP}:8080 -r ${IP}:8444 -m
|
ipvsadm -a -t ${EXTIP}:8080 -r ${IP}:8444 -m
|
||||||
|
INSTANCE=$(echo $cont|tr - _)
|
||||||
|
cat >> $CF << EOF
|
||||||
|
<URL "http://$IP:8442/">
|
||||||
|
Plugin "pybitmessagestatus"
|
||||||
|
Instance "$INSTANCE"
|
||||||
|
User "pybitmessage"
|
||||||
|
Password "$PASSWORD"
|
||||||
|
Post "{\"jsonrpc\":\"2.0\",\"id\":\"id\",\"method\":\"clientStatus\",\"params\":[]}"
|
||||||
|
<Key "result/networkConnections">
|
||||||
|
Type "gauge"
|
||||||
|
Instance "networkconnections"
|
||||||
|
</Key>
|
||||||
|
<Key "result/numberOfPubkeysProcessed">
|
||||||
|
Type "counter"
|
||||||
|
Instance "numberofpubkeysprocessed"
|
||||||
|
</Key>
|
||||||
|
<Key "result/numberOfMessagesProcessed">
|
||||||
|
Type "counter"
|
||||||
|
Instance "numberofmessagesprocessed"
|
||||||
|
</Key>
|
||||||
|
<Key "result/numberOfBroadcastsProcessed">
|
||||||
|
Type "counter"
|
||||||
|
Instance "numberofbroadcastsprocessed"
|
||||||
|
</Key>
|
||||||
|
</URL>
|
||||||
|
EOF
|
||||||
done
|
done
|
||||||
|
echo "</Plugin>" >> $CF
|
||||||
|
systemctl restart collectd
|
||||||
|
|
||||||
ipvsadm -l
|
ipvsadm -l -n
|
||||||
|
|
Reference in New Issue
Block a user