Add code to run bootstrap server

This commit is contained in:
Peter Šurda 2024-02-28 07:40:08 +08:00
parent 7ed76d9e3e
commit d4c6db4997
Signed by: PeterSurda
GPG Key ID: 3E47497CF67ABB95
3 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,10 @@
version: "3"
name: pybitmessage
services:
bootstrap:
image: pybitmessage/bootstrap:latest
build: ..
ports:
- 127.0.0.1::8444
deploy:
replicas: $THREADS

View File

@ -0,0 +1,24 @@
#!/bin/bash
apt -y install curl jq ipvsadm
EXTIP=$(curl -s telnetmyip.com|jq -r .ip)
THREADS=$(nproc --all)
echo "THREADS=$THREADS" > .env
ipvsadm -C
ipvsadm -A -t ${EXTIP}:8444 -s rr
ipvsadm -A -t ${EXTIP}:8080 -s rr
docker compose up -d
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
done
ipvsadm -l

View File

@ -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