Skip to content

Commit bdcf5a9

Browse files
committed
cluster: ready repo for subtree into plebnet-playground-docker
1 parent d77da09 commit bdcf5a9

File tree

3 files changed

+141
-21
lines changed

3 files changed

+141
-21
lines changed

GNUmakefile

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
SHELL := /bin/bash
2+
3+
PWD ?= pwd_unknown
4+
5+
THIS_FILE := $(lastword $(MAKEFILE_LIST))
6+
export THIS_FILE
7+
TIME := $(shell date +%s)
8+
export TIME
9+
10+
ifeq ($(docker),)
11+
DOCKER := $(shell which docker)
12+
else
13+
DOCKER := $(docker)
14+
endif
15+
export DOCKER
16+
17+
ifeq ($(compose),)
18+
DOCKER_COMPOSE := $(shell which docker-compose)
19+
else
20+
DOCKER_COMPOSE := $(compose)
21+
endif
22+
export DOCKER_COMPOSE
23+
24+
25+
26+
PYTHON := $(shell which python)
27+
export PYTHON
28+
PYTHON2 := $(shell which python2)
29+
export PYTHON2
30+
PYTHON3 := $(shell which python3)
31+
export PYTHON3
32+
33+
PIP := $(shell which pip)
34+
export PIP
35+
PIP2 := $(shell which pip2)
36+
export PIP2
37+
PIP3 := $(shell which pip3)
38+
export PIP3
39+
40+
python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python3 --version 2>&1)))
41+
python_version_major := $(word 1,${python_version_full})
42+
python_version_minor := $(word 2,${python_version_full})
43+
python_version_patch := $(word 3,${python_version_full})
44+
45+
my_cmd.python.3 := $(PYTHON3) some_script.py3
46+
my_cmd := ${my_cmd.python.${python_version_major}}
47+
48+
PYTHON_VERSION := ${python_version_major}.${python_version_minor}.${python_version_patch}
49+
PYTHON_VERSION_MAJOR := ${python_version_major}
50+
PYTHON_VERSION_MINOR := ${python_version_minor}
51+
52+
export python_version_major
53+
export python_version_minor
54+
export python_version_patch
55+
export PYTHON_VERSION
56+
57+
# PROJECT_NAME defaults to name of the current directory.
58+
ifeq ($(project),)
59+
PROJECT_NAME := $(notdir $(PWD))
60+
else
61+
PROJECT_NAME := $(project)
62+
endif
63+
export PROJECT_NAME
64+
65+
66+
67+
68+
.PHONY: venv
69+
venv:
70+
test -d .venv || $(PYTHON3) -m virtualenv .venv
71+
( \
72+
source .venv/bin/activate; pip install -r requirements.txt; \
73+
);
74+
@echo "To activate (venv)"
75+
@echo "try:"
76+
@echo ". .venv/bin/activate"
77+
@echo "or:"
78+
@echo "make test-venv"
79+
##: test-venv source .venv/bin/activate; pip install -r requirements.txt;
80+
test-venv:
81+
# insert test commands here
82+
test -d .venv || $(PYTHON3) -m virtualenv .venv
83+
( \
84+
source .venv/bin/activate; pip install -r requirements.txt; \
85+
);
86+
#######################
87+
.PHONY: prune-network
88+
prune-network:
89+
$(DOCKER_COMPOSE) -p $(PROJECT_NAME) down
90+
docker network rm $(PROJECT_NAME)_default 2>/dev/null || echo "retry..."
91+
#######################

up-generic.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ python plebnet_generate.py TRIPLET=$TRIPLET bitcoind=$bitcoind lnd=$lnd tor=$tor
1111

1212
#Remove
1313
docker-compose down
14-
sudo rm -rf volumes
15-
1614

1715
#Create Datafile
16+
mkdir -p volumes
1817

19-
mkdir volumes
2018
for (( i=0; i<=$bitcoind-1; i++ ))
2119
do
2220
mkdir -p volumes/bitcoin_datadir_$i

up-x64.sh

+49-18
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,68 @@
11
if [[ $# -ne 1 ]];
2-
then
2+
then
33
echo "up-x64.sh (# of instances)"
44
exit
55
fi
66

7+
while ! docker system info > /dev/null 2>&1; do
8+
echo "Waiting for docker to start..."
9+
if [[ "$(uname -s)" == "Linux" ]]; then
10+
systemctl restart docker.service
11+
fi
12+
if [[ "$(uname -s)" == "Darwin" ]]; then
13+
open --background -a /./Applications/Docker.app/Contents/MacOS/Docker
14+
fi
15+
16+
sleep 1;
17+
18+
done
19+
720
#This is for internal testing only
8-
declare TRIPLET=x86_64-linux-gnu
9-
declare torcount=$(expr $1 / 8 + 1)
21+
TRIPLET=x86_64-linux-gnu
22+
torcount=`expr $1 / 3 + 1`
23+
echo $torcount
1024
python plebnet_generate.py TRIPLET=x86_64-linux-gnu bitcoind=$1 lnd=$1 tor=$torcount
1125

1226
#Remove
13-
docker-compose down
14-
sudo rm -rf volumes
15-
27+
docker compose down || docker-compose down
28+
sudo -s chown -R $(id -u) *
29+
sudo -s rm -rf volumes
30+
1631
#Create Datafile
32+
sudo -s mkdir volumes
1733

18-
mkdir volumes
34+
sudo -s chown -R $(id -u) *
1935
declare n=$1
2036
for (( i=0; i<=n-1; i++ ))
2137
do
22-
mkdir volumes/lnd_datadir_$i
23-
mkdir volumes/bitcoin_datadir_$i
24-
38+
echo $i
39+
mkdir -p volumes/lnd_datadir_$i
40+
mkdir -p volumes/bitcoin_datadir_$i
41+
2542
# mkdir volumes/tor_torrcdir_1
2643
done
27-
for (( i=0; i<=torcount-1; i++ ))
28-
do
29-
mkdir volumes/tor_datadir_$i
30-
mkdir volumes/tor_servicesdir_$i
31-
mkdir volumes/tor_torrcdir_$i
44+
for (( i=0; i<=torcount; i++ ))
45+
do
46+
echo $i
47+
mkdir -p volumes/tor_datadir_$i
48+
mkdir -p volumes/tor_servicesdir_$i
49+
mkdir -p volumes/tor_torrcdir_$i
50+
done
51+
52+
while ! docker system info > /dev/null 2>&1; do
53+
echo "Waiting for docker to start..."
54+
if [[ "$(uname -s)" == "Linux" ]]; then
55+
systemctl restart docker.service
56+
fi
57+
if [[ "$(uname -s)" == "Darwin" ]]; then
58+
open --background -a /./Applications/Docker.app/Contents/MacOS/Docker
59+
fi
60+
61+
sleep 1;
62+
3263
done
3364

34-
docker-compose build --build-arg TRIPLET=$TRIPLET
35-
docker-compose up -d
65+
docker compose build --parallel --build-arg TRIPLET=$TRIPLET || docker-compose build --parallel --build-arg TRIPLET=$TRIPLET
66+
docker compose up --remove-orphans -d || docker-compose up --remove-orphans -d
67+
3668

37-

0 commit comments

Comments
 (0)