Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
550fe7daa3 | |||
664e57db37 | |||
17d1e901c0 | |||
d4c6db4997 |
9
docker-compose/docker-compose.yml
Normal file
9
docker-compose/docker-compose.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
version: "3"
|
||||||
|
name: pybitmessage
|
||||||
|
services:
|
||||||
|
bootstrap:
|
||||||
|
image: pybitmessage/bootstrap:latest
|
||||||
|
build: ..
|
||||||
|
env_file: .env
|
||||||
|
deploy:
|
||||||
|
replicas: $THREADS
|
70
docker-compose/start-loadbalancer.sh
Executable file
70
docker-compose/start-loadbalancer.sh
Executable file
|
@ -0,0 +1,70 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
apt -y install curl jq ipvsadm libyajl2
|
||||||
|
|
||||||
|
EXTIP=$(curl -s telnetmyip.com|jq -r .ip)
|
||||||
|
if [ ! -e .env ]; then
|
||||||
|
THREADS=$(nproc --all)
|
||||||
|
PASSWORD=$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo)
|
||||||
|
cat > .env << EOF
|
||||||
|
THREADS=$THREADS
|
||||||
|
PASSWORD=$PASSWORD
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
. .env
|
||||||
|
fi
|
||||||
|
|
||||||
|
ipvsadm -C
|
||||||
|
ipvsadm -A -t ${EXTIP}:8444 -s rr
|
||||||
|
ipvsadm -A -t ${EXTIP}:8080 -s rr
|
||||||
|
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
CF=/etc/collectd/collectd.conf.d/curl_json.conf.new
|
||||||
|
CF_LIVE=/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
|
||||||
|
cont="pybitmessage-bootstrap-${i}"
|
||||||
|
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $cont 2>/dev/null)
|
||||||
|
[ -z "$IP" ] && continue
|
||||||
|
echo "Adding $IP"
|
||||||
|
ipvsadm -a -t ${EXTIP}:8444 -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 "api"
|
||||||
|
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
|
||||||
|
echo "</Plugin>" >> $CF
|
||||||
|
|
||||||
|
if ! cmp -s $CF $CF_LIVE; then
|
||||||
|
mv $CF $CF_LIVE
|
||||||
|
systemctl restart collectd
|
||||||
|
fi
|
||||||
|
|
||||||
|
ipvsadm -l -n
|
|
@ -3,13 +3,15 @@
|
||||||
# Setup the environment for docker container
|
# Setup the environment for docker container
|
||||||
APIUSER=${USER:-api}
|
APIUSER=${USER:-api}
|
||||||
APIPASS=${PASSWORD:-$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo)}
|
APIPASS=${PASSWORD:-$(tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo)}
|
||||||
|
IP=$(hostname -i)
|
||||||
|
|
||||||
echo "\napiusername: $APIUSER\napipassword: $APIPASS"
|
echo "\napiusername: $APIUSER\napipassword: $APIPASS"
|
||||||
|
|
||||||
sed -i -e "s|\(apiinterface = \).*|\10\.0\.0\.0|g" \
|
sed -i -e "s|\(apiinterface = \).*|\1$IP|g" \
|
||||||
-e "s|\(apivariant = \).*|\1json|g" \
|
-e "s|\(apivariant = \).*|\1json|g" \
|
||||||
-e "s|\(apiusername = \).*|\1$APIUSER|g" \
|
-e "s|\(apiusername = \).*|\1$APIUSER|g" \
|
||||||
-e "s|\(apipassword = \).*|\1$APIPASS|g" \
|
-e "s|\(apipassword = \).*|\1$APIPASS|g" \
|
||||||
|
-e "s|\(bind = \).*|\1$IP|g" \
|
||||||
-e "s|apinotifypath = .*||g" ${BITMESSAGE_HOME}/keys.dat
|
-e "s|apinotifypath = .*||g" ${BITMESSAGE_HOME}/keys.dat
|
||||||
|
|
||||||
# Run
|
# Run
|
||||||
|
|
Reference in New Issue
Block a user