From dbfef4485da330373ed7632777f3d0dd9e9137b0 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 15 Mar 2021 09:45:54 -0500 Subject: [PATCH] better healthcheck log --- bin/process_pending_btc_transactions | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/process_pending_btc_transactions b/bin/process_pending_btc_transactions index f23a2556a8d415868d4d114b7748891bc61fc0e2..4f8f5e91e6524c4c662886c48bac80982501a15b 100755 --- a/bin/process_pending_btc_transactions +++ b/bin/process_pending_btc_transactions @@ -32,7 +32,7 @@ CONFIG = .new(safe: Dhall::Coder::JSON_LIKE + [Symbol, Proc]) .load(ARGV[0], transform_keys: :to_sym) -Net::HTTP.post_form(URI("#{CONFIG[:healthchecks_url]}/start"), {}) +Net::HTTP.post(URI("#{CONFIG[:healthchecks_url]}/start"), "") REDIS = Redis.new ELECTRUM = Electrum.new(**CONFIG[:electrum]) @@ -243,7 +243,7 @@ class Customer end end -REDIS.hgetall("pending_btc_transactions").each do |(txid, customer_id)| +done = REDIS.hgetall("pending_btc_transactions").map do |(txid, customer_id)| tx_hash, address = txid.split("/", 2) transaction = ELECTRUM.gettransaction(tx_hash) next unless transaction.confirmations >= CONFIG[:required_confirmations] @@ -259,10 +259,11 @@ REDIS.hgetall("pending_btc_transactions").each do |(txid, customer_id)| customer.add_btc_credit(txid, btc, amount) customer.plan.activate_any_pending_plan! REDIS.hdel("pending_btc_transactions", txid) + txid else warn "No plan for #{customer_id} cannot save #{txid}" end end end -Net::HTTP.post_form(URI(CONFIG[:healthchecks_url].to_s), {}) +Net::HTTP.post(URI(CONFIG[:healthchecks_url].to_s), done.compact.join("\n"))