From 1355a2b4a224b860a58d4055422ac21835f5aedf Mon Sep 17 00:00:00 2001 From: /rootzoll Date: Tue, 1 Aug 2023 00:46:35 +0200 Subject: [PATCH] Adjust lnd.conf for healthcheck parameters (#4052) * Adjust lnd.conf for healthcheck parameters, allowing for longer timeout intervalls for rpc connection (#4010) * adding healthcheck values --------- Co-authored-by: HODLmeTight <35168804+TrezorHannes@users.noreply.github.com> --- home.admin/assets/lnd.bitcoin.conf | 6 +++ home.admin/config.scripts/lnd.check.sh | 54 +++++++++++++++----------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/home.admin/assets/lnd.bitcoin.conf b/home.admin/assets/lnd.bitcoin.conf index ca5cf575f..923676a16 100755 --- a/home.admin/assets/lnd.bitcoin.conf +++ b/home.admin/assets/lnd.bitcoin.conf @@ -37,3 +37,9 @@ autopilot.allocation=0.6 [bolt] db.bolt.auto-compact=true db.bolt.auto-compact-min-age=672h + +# Allow for longer latency, especially useful for <8GB RAM Pi and congested mempool +[healthcheck] +healthcheck.chainbackend.attempts=3 +healthcheck.chainbackend.timeout=2m0s +healthcheck.chainbackend.interval=1m30s diff --git a/home.admin/config.scripts/lnd.check.sh b/home.admin/config.scripts/lnd.check.sh index 97b12e687..45b4284d8 100755 --- a/home.admin/config.scripts/lnd.check.sh +++ b/home.admin/config.scripts/lnd.check.sh @@ -311,8 +311,6 @@ if [ "$1" == "prestart" ]; then fi ##### RPCMIDDLEWARE SECTION ##### - - # [rpcmiddleware] sectionName="rpcmiddleware" echo "# [${sectionName}] config ..." @@ -346,6 +344,38 @@ if [ "$1" == "prestart" ]; then # SET/UPDATE rpcmiddleware.enable setting ${lndConfFile} ${insertLine} "rpcmiddleware.enable" "true" + ##### HEALTHCHECK SECTION ##### + sectionName="healthcheck" + echo "# [${sectionName}] config ..." + + # make sure lnd config has a [healthcheck] section + sectionExists=$(cat ${lndConfFile} | grep -c "^\[${sectionName}\]") + echo "# sectionExists(${sectionExists})" + if [ "${sectionExists}" == "0" ]; then + echo "# adding section [${sectionName}]" + echo " +[${sectionName}] +" | tee -a ${lndConfFile} + fi + + # get line number of [healthcheck] section + sectionLine=$(cat ${lndConfFile} | grep -n "^\[${sectionName}\]" | cut -d ":" -f1) + echo "# sectionLine(${sectionLine})" + insertLine=$(expr $sectionLine + 1) + echo "# insertLine(${insertLine})" + fileLines=$(wc -l ${lndConfFile} | cut -d " " -f1) + echo "# fileLines(${fileLines})" + if [ ${fileLines} -lt ${insertLine} ]; then + echo "# adding new line for inserts" + echo " +" | tee -a ${lndConfFile} + fi + + # SET/UPDATE healthcheck values + setting ${lndConfFile} ${insertLine} "healthcheck.chainbackend.attempts" "3" + setting ${lndConfFile} ${insertLine} "healthcheck.chainbackend.timeout" "2m0s" + setting ${lndConfFile} ${insertLine} "healthcheck.chainbackend.interval" "1m30s" + echo "# OK PRESTART DONE" ###################################################################### @@ -419,26 +449,6 @@ elif [ "$1" == "basic-setup" ]; then echo "err='$(netprefix)lnd.conf: blockchain network in $(netprefix)lnd.conf (${lndNetwork}) is different from raspiblitz.conf (${network})'" fi - # # get chain from config (TESTNET / MAINNET) - # lndChain="" - # source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.mainnet" | sed 's/^[a-z]*\.//g') - # source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.testnet" | sed 's/^[a-z]*\.//g') - # if [ "${mainnet}" == "1" ] && [ "${testnet}" == "1" ]; then - # echo "err='lnd.conf: mainnet and testnet are set active at the same time'" - # elif [ "${mainnet}" == "1" ]; then - # lndChain="main" - # elif [ "${testnet}" == "1" ]; then - # lndChain="test" - # else - # echo "err='lnd.conf: neither testnet or mainnet is set active (raspiblitz needs one of them active in lnd.conf)'" - # fi - # echo "chain='${lndChain}'" - # - # # check if chain is same the raspiblitz config - # if [ "${chain}" != "${lndChain}" ]; then - # echo "err='lnd.conf: testnet/mainnet in lnd.conf (${lndChain}) is different from raspiblitz.conf (${chain})'" - # fi - # check for admin macaroon exist (on HDD) adminMacaroonExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c 'admin.macaroon') if [ ${adminMacaroonExists} -gt 0 ]; then