More work on service managment

This commit is contained in:
AaronDewes 2022-03-11 06:17:26 +00:00
parent 69bae236c4
commit 06aa65fa92
9 changed files with 81 additions and 28 deletions

3
.gitignore vendored
View File

@ -49,6 +49,5 @@ db/citadel-seed/*
!**/*.license !**/*.license
services/installed.json services/installed.json
services/installed.yaml services/installed.yml
use-core-upstream

View File

@ -77,8 +77,8 @@ services:
networks: networks:
default: default:
ipv4_address: $BITCOIN_IP ipv4_address: $BITCOIN_IP
lnd: lightning:
container_name: lnd container_name: lightning
image: lightninglabs/lnd:v0.14.2-beta@sha256:8318a24a3ad7319e424253eb56efcbf38e820ebc6d6b6edeec6a8a4e3e9314a0 image: lightninglabs/lnd:v0.14.2-beta@sha256:8318a24a3ad7319e424253eb56efcbf38e820ebc6d6b6edeec6a8a4e3e9314a0
user: 1000:1000 user: 1000:1000
depends_on: depends_on:

12
scripts/configure vendored
View File

@ -124,18 +124,6 @@ def parse_dotenv(file_path):
exit(1) exit(1)
return envVars return envVars
KNOTS_REINDEX_AUTO="reindex=auto"
BITCOIN_CORE_IMAGE="lncm/bitcoind:v22.0@sha256:37a1adb29b3abc9f972f0d981f45e41e5fca2e22816a023faa9fdc0084aa4507"
if os.path.isfile('../use-core-upstream') or os.path.isfile('./use-core-upstream'):
KNOTS_REINDEX_AUTO=""
# Also, open the docker-compose file and replace the image of the bitcoin service
# with the upstream version of bitcoin core
with open(os.path.join(CITADEL_ROOT, "docker-compose.yml"), 'r') as file:
docker_compose_yml = yaml.safe_load(file)
docker_compose_yml['services']['bitcoin']['image'] = BITCOIN_CORE_IMAGE
with open(os.path.join(CITADEL_ROOT, "docker-compose.yml"), 'w') as file:
yaml.dump(docker_compose_yml, file, sort_keys=False)
########################################################## ##########################################################
############ Generate configuration variables ############ ############ Generate configuration variables ############
########################################################## ##########################################################

View File

@ -9,8 +9,7 @@ events/signals
logs/* logs/*
app-data/* app-data/*
apps/networking.json apps/networking.json
use-core-upstream
nginx/* nginx/*
services/installed.json services/installed.yml
apps/sourceMap.json apps/sourceMap.json
apps/.updateignore apps/.updateignore

18
services/bitcoin/core.yml Normal file
View File

@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: 2021-2022 Citadel and contributors
#
# SPDX-License-Identifier: GPL-3.0-or-later
bitcoin:
container_name: bitcoin
image: lncm/bitcoind:v22.0@sha256:37a1adb29b3abc9f972f0d981f45e41e5fca2e22816a023faa9fdc0084aa4507
depends_on:
- tor
volumes:
- ${PWD}/bitcoin:/data/.bitcoin
restart: on-failure
stop_grace_period: 1m
ports:
- $BITCOIN_P2P_PORT:$BITCOIN_P2P_PORT
networks:
default:
ipv4_address: $BITCOIN_IP

View File

@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: 2021-2022 Citadel and contributors
#
# SPDX-License-Identifier: GPL-3.0-or-later
bitcoin:
container_name: bitcoin
image: nolim1t/bitcoinknots:v22.0.knots20211108@sha256:a475da2b2ecda55fcc65ea23e1a36c58b2c10549f1c3d3bb3c31c7dda1127354
depends_on:
- tor
volumes:
- ${PWD}/bitcoin:/data/.bitcoin
restart: on-failure
stop_grace_period: 1m
ports:
- $BITCOIN_P2P_PORT:$BITCOIN_P2P_PORT
networks:
default:
ipv4_address: $BITCOIN_IP

View File

@ -0,0 +1,21 @@
lightning:
container_name: lightning
image: lightninglabs/lnd:v0.14.2-beta@sha256:8318a24a3ad7319e424253eb56efcbf38e820ebc6d6b6edeec6a8a4e3e9314a0
user: 1000:1000
depends_on:
- tor
- bitcoin
volumes:
- ${PWD}/lnd:/data/.lnd
- ${PWD}/walletpassword:/walletpassword
environment:
HOME: /data
restart: on-failure
stop_grace_period: 5m30s
ports:
- 9735:9735
- $LND_REST_PORT:$LND_REST_PORT
- $LND_GRPC_PORT:$LND_GRPC_PORT
networks:
default:
ipv4_address: $LND_IP

View File

@ -48,12 +48,16 @@ def setService(name, implementation):
# Save the service name in nodeRoot/services/installed.json, which is a JSON file with a list of installed services # Save the service name in nodeRoot/services/installed.json, which is a JSON file with a list of installed services
# If the file doesn't exist, put [] in it, then run the code below # If the file doesn't exist, put [] in it, then run the code below
try: try:
with open(os.path.join(nodeRoot, "services", "installed.yaml"), 'r') as stream: with open(os.path.join(nodeRoot, "services", "installed.yml"), 'r') as stream:
installed = yaml.safe_load(stream) installed = yaml.safe_load(stream)
except FileNotFoundError: except FileNotFoundError:
installed = {} installed = {
"electrum": "electrs",
"lightning": "lnd",
"bitcoin": "knots"
}
installed[name] = implementation installed[name] = implementation
with open(os.path.join(nodeRoot, "services", "installed.yaml"), 'w') as stream: with open(os.path.join(nodeRoot, "services", "installed.yml"), 'w') as stream:
yaml.dump(installed, stream, sort_keys=False) yaml.dump(installed, stream, sort_keys=False)
@ -77,25 +81,31 @@ def uninstallService(name):
yaml.dump(compose, stream, sort_keys=False) yaml.dump(compose, stream, sort_keys=False)
# Save the service name in nodeRoot/services/installed.json, which is a JSON file with a list of installed services # Save the service name in nodeRoot/services/installed.json, which is a JSON file with a list of installed services
try: try:
with open(os.path.join(nodeRoot, "services", "installed.yaml"), 'r') as stream: with open(os.path.join(nodeRoot, "services", "installed.yml"), 'r') as stream:
installed = yaml.safe_load(stream) installed = yaml.safe_load(stream)
except FileNotFoundError: except FileNotFoundError:
installed = {} installed = {
"electrum": "electrs",
"lightning": "lnd",
"bitcoin": "knots"
}
try: try:
del installed[name] del installed[name]
except KeyError: except KeyError:
pass pass
with open(os.path.join(nodeRoot, "services", "installed.yaml"), 'w') as stream: with open(os.path.join(nodeRoot, "services", "installed.yml"), 'w') as stream:
yaml.dump(installed, stream, sort_keys=False) yaml.dump(installed, stream, sort_keys=False)
# install all services from installed.json # install all services from installed.json
def installServices(): def installServices():
try: try:
with open(os.path.join(nodeRoot, "services", "installed.yaml"), 'r') as stream: with open(os.path.join(nodeRoot, "services", "installed.yml"), 'r') as stream:
installed = yaml.safe_load(stream) installed = yaml.safe_load(stream)
except FileNotFoundError: except FileNotFoundError:
installed = { installed = {
"electrum": "electrs" "electrum": "electrs",
"lightning": "lnd",
"bitcoin": "knots"
} }
for key, value in installed.items(): for key, value in installed.items():

View File

@ -35,8 +35,8 @@ blockfilterindex=1
peerbloomfilters=1 peerbloomfilters=1
peerblockfilters=1 peerblockfilters=1
# Bitcoin Knots only # Bitcoin Knots only, Bitcoin Core simply ignores this
<knots-reindex-auto> reindex=auto
<external-ip> <external-ip>