Repository navigation
lnd: restart the service after every exit - #73
Merged
Merged
Conversation
prusnak
previously requested changes
Oct 20, 2026
ostermayer
force-pushed
the
lnd-restart-always
branch
from
October 22, 2026 23:05
423c03e to
ce9ed21
Compare
This was referenced Oct 23, 2026
When bitcoind stays unreachable, lnd's chain backend health check (3 attempts, 1 min apart by default) requests a graceful shutdown, and lnd exits with status 0. `Restart = "on-failure"` never restarted it, so lnd stayed down after bitcoind came back. A Lightning node that is down cannot react to a stale-state force close. `Restart = "always"` brings lnd back after `RestartSec`. Trade-off: `lncli stop` now also results in a restart; an operator who wants lnd down uses `systemctl stop lnd`, which never triggers `Restart=`. Test: `lnd-restart-on-clean-exit` (regtest scenarios with lnd) runs `lncli stop`, waits for a new lnd InvocationID, waits for the unit to be active and for `lncli getinfo` to succeed. Follow-up to bitcoinix#62. Assisted-by: Codex (GPT-6)
prusnak
force-pushed
the
lnd-restart-always
branch
from
October 23, 2026 09:11
ce9ed21 to
7ce6f12
Compare
Add a config version 0.1.2 notice for LND users and document using systemctl stop lnd for maintenance now that lncli stop triggers an automatic restart. Assisted-by: Codex (GPT-6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #62.
Problem
lnd checks its chain backend at regular intervals, and when bitcoind stays unreachable the check fails 3 times, 1 minute apart by default, after which lnd shuts down cleanly and exits with status 0. The lnd unit has
Restart = "on-failure", and systemd doesn't restart a unit that exits with status 0, so lnd stays down after bitcoind comes back. A Lightning node that's down can't react to a stale-state force close, which puts funds at risk.Change
modules/lnd.nix:Restart = "always", with the reason in the comment.systemctl stop lndstill stops lnd for good, because an explicit stop never triggersRestart=. The trade-off is thatlncli stopnow results in a restart after 10 s, so an operator who wants lnd down usessystemctl stop lnd.Review
Models used on this PR: Fable 5.1 and Opus 5.5 for the changes. Kimi K3 and GLM 5.3, both at max thinking, reviewed the first revisions. GPT-6 Astra at xhigh reasoning found that the first test version could pass on
master, because a restarting loopd pulled lnd back up throughRequires=. DeepSeek V4.1 Flash 1017 and GLM 5.3 at max thinking, plus Astra, reviewed the rebased revision and found nothing inmodules/lnd.nixor the test. Their findings in other files are master code that open issues already track.Testing
New test
lnd-restart-on-clean-exitin the regtest scenarios with lnd. It pauses the charge-lnd timer first, because charge-lndrequireslnd and a timer tick during the test would start lnd by itself and hide a missingRestart=, while RTL onlywantslnd and keeps running. Then it runslncli stop, waits for a new lndInvocationID, waits for the unit to be active, runslncli getinfo, and starts the timer again.regtest, this branchlnd.service: Deactivated successfullyafterlncli stop, so the exit status is 0, and thenScheduled restart jobmaster(red)on-failurethe clean exit leaves the unit inactive and theInvocationIDwait times out