fix(docker): run ATM in background, fix Zeus lndconnect

- Launch ATM with --background flag when using --machine
- ATM logs written to .state/atm.log instead of terminal
- Fix lndconnect generation to read certs via docker exec
- Status output remains visible after ATM starts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-02-15 14:34:09 -05:00
commit f70c2b8878

View file

@ -265,12 +265,25 @@ generate_lndconnect() {
local cert_path="$lnd_data/tls.cert"
local mac_path="$lnd_data/data/chain/bitcoin/regtest/admin.macaroon"
if [[ ! -f "$cert_path" ]] || [[ ! -f "$mac_path" ]]; then
# Check if files exist and are readable
if [[ ! -r "$cert_path" ]]; then
# Try reading cert via docker
local cert_b64=$(docker exec lnbits-lnd-3-1 base64 -w0 /root/.lnd/tls.cert 2>/dev/null | tr '+/' '-_' | tr -d '=')
local mac_b64=$(docker exec lnbits-lnd-3-1 base64 -w0 /root/.lnd/data/chain/bitcoin/regtest/admin.macaroon 2>/dev/null | tr '+/' '-_' | tr -d '=')
if [[ -n "$cert_b64" ]] && [[ -n "$mac_b64" ]]; then
echo "lndconnect://${local_ip}:${rest_port}?cert=${cert_b64}&macaroon=${mac_b64}"
return 0
fi
return 1
fi
local cert_b64=$(base64 -w0 "$cert_path" | tr '+/' '-_' | tr -d '=')
local mac_b64=$(base64 -w0 "$mac_path" | tr '+/' '-_' | tr -d '=')
local mac_b64=$(sudo base64 -w0 "$mac_path" 2>/dev/null | tr '+/' '-_' | tr -d '=')
if [[ -z "$mac_b64" ]]; then
return 1
fi
echo "lndconnect://${local_ip}:${rest_port}?cert=${cert_b64}&macaroon=${mac_b64}"
}
@ -444,10 +457,10 @@ cmd_up() {
# 10. Show status
show_status
# 11. Launch ATM if requested
# 11. Launch ATM if requested (in background so status stays visible)
if [[ "$launch_machine" == "true" ]]; then
echo ""
cmd_atm
cmd_atm --background
fi
}
@ -567,6 +580,15 @@ cmd_mine() {
cmd_atm() {
local atm_dir="$PROJECT_DIR/apps/machine"
local background=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--background|-b) background=true; shift ;;
*) shift ;;
esac
done
if [[ ! -d "$atm_dir" ]]; then
error "ATM app not found at $atm_dir"
@ -583,14 +605,26 @@ cmd_atm() {
fi
fi
log "Starting ATM application..."
echo ""
echo -e "${CYAN}ATM Mock Mode:${NC}"
echo " - Press 'b' to insert a bill (simulates cash insertion)"
echo " - Use the UI to complete transactions"
echo ""
cd "$atm_dir" && pnpm dev
if [[ "$background" == "true" ]]; then
local log_file="$STATE_DIR/atm.log"
log "Starting ATM application in background..."
log "Logs: $log_file"
(cd "$atm_dir" && nohup pnpm dev > "$log_file" 2>&1 &)
sleep 2
if pgrep -f "electron.*machine" > /dev/null; then
success "ATM app started (PID: $(pgrep -f 'electron.*machine' | head -1))"
else
warn "ATM may still be starting. Check logs: tail -f $log_file"
fi
else
log "Starting ATM application..."
echo ""
echo -e "${CYAN}ATM Mock Mode:${NC}"
echo " - Press 'b' to insert a bill (simulates cash insertion)"
echo " - Use the UI to complete transactions"
echo ""
cd "$atm_dir" && pnpm dev
fi
}
#############################################################################