feat: add funding_source_max_retries env setting (#2404)
* feat: add `funding_source_max_retries` env setting * feat: default to zero retries * feat: exponential retry time increase * chore: Let's use the same value as the default Co-authored-by: Pavol Rusnak <pavol@rusnak.io> * feat: using 0.25 leads to less awkward numbers Co-authored-by: Pavol Rusnak <pavol@rusnak.io> --------- Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
This commit is contained in:
parent
e9e69d9d17
commit
adb8f9bdec
3 changed files with 7 additions and 3 deletions
|
|
@ -34,6 +34,9 @@ LNBITS_BACKEND_WALLET_CLASS=VoidWallet
|
||||||
# VoidWallet is just a fallback that works without any actual Lightning capabilities,
|
# VoidWallet is just a fallback that works without any actual Lightning capabilities,
|
||||||
# just so you can see the UI before dealing with this file.
|
# just so you can see the UI before dealing with this file.
|
||||||
|
|
||||||
|
# How many times to retry connectiong to the Funding Source before defaulting to the VoidWallet
|
||||||
|
# FUNDING_SOURCE_MAX_RETRIES=4
|
||||||
|
|
||||||
# Invoice expiry for LND, CLN, Eclair, LNbits funding sources
|
# Invoice expiry for LND, CLN, Eclair, LNbits funding sources
|
||||||
LIGHTNING_INVOICE_EXPIRY=3600
|
LIGHTNING_INVOICE_EXPIRY=3600
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -180,8 +180,7 @@ async def check_funding_source() -> None:
|
||||||
|
|
||||||
WALLET = get_wallet_class()
|
WALLET = get_wallet_class()
|
||||||
|
|
||||||
sleep_time = 5
|
max_retries = settings.funding_source_max_retries
|
||||||
max_retries = 5
|
|
||||||
retry_counter = 0
|
retry_counter = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
@ -203,12 +202,13 @@ async def check_funding_source() -> None:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error connecting to {WALLET.__class__.__name__}: {e}")
|
logger.error(f"Error connecting to {WALLET.__class__.__name__}: {e}")
|
||||||
|
|
||||||
if retry_counter == max_retries:
|
if retry_counter >= max_retries:
|
||||||
set_void_wallet_class()
|
set_void_wallet_class()
|
||||||
WALLET = get_wallet_class()
|
WALLET = get_wallet_class()
|
||||||
break
|
break
|
||||||
|
|
||||||
retry_counter += 1
|
retry_counter += 1
|
||||||
|
sleep_time = 0.25 * (2**retry_counter)
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Retrying connection to backend in {sleep_time} seconds... "
|
f"Retrying connection to backend in {sleep_time} seconds... "
|
||||||
f"({retry_counter}/{max_retries})"
|
f"({retry_counter}/{max_retries})"
|
||||||
|
|
|
||||||
|
|
@ -377,6 +377,7 @@ class EnvSettings(LNbitsSettings):
|
||||||
log_retention: str = Field(default="3 months")
|
log_retention: str = Field(default="3 months")
|
||||||
server_startup_time: int = Field(default=time())
|
server_startup_time: int = Field(default=time())
|
||||||
cleanup_wallets_days: int = Field(default=90)
|
cleanup_wallets_days: int = Field(default=90)
|
||||||
|
funding_source_max_retries: int = Field(default=4)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_default_extension_path(self) -> bool:
|
def has_default_extension_path(self) -> bool:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue