From 6c1822c8fcc43cdcc3072cb30d4b7defa59c4d17 Mon Sep 17 00:00:00 2001 From: wiz Date: Tue, 14 Jul 2026 17:15:56 +0900 Subject: [PATCH] ops: Add liquid to warm cache script, clean up SSR stuff --- production/nginx-cache-warmer | 93 +++++++++++++------------------ production/nginx-cache-warmer-ssr | 6 ++ 2 files changed, 45 insertions(+), 54 deletions(-) diff --git a/production/nginx-cache-warmer b/production/nginx-cache-warmer index a24898a30..839356027 100755 --- a/production/nginx-cache-warmer +++ b/production/nginx-cache-warmer @@ -1,44 +1,17 @@ #!/usr/bin/env zsh -delay=0.25 -hostname=$(hostname) -slugs=(`curl -sSL https://${hostname}/api/v1/mining/pools/3y|jq -r -S '(.pools[].slug)'`) - -warmSlurp() -{ - echo "$1" - curl -o /dev/null -s -H 'User-Agent: Googlebot' "$1" -} - -warmUnfurl() -{ - echo "$1" - curl -o /dev/null -s -H 'User-Agent: Twitterbot' "$1" -} +delay=0.5 +hostnameBitcoin=127.0.0.1:82 +hostnameLiquid=127.0.0.1:83 warm() { echo "$1" - curl -o /dev/null -s "$1" + time curl -o /dev/null -s "$1" + sleep $delay # delay between queries to not DoS mariadb + echo } -warmSlurpURLs=( - '/' - '/mining' - '/lightning' - '/graphs' - '/docs' - '/docs/faq' - '/docs/api/rest' - '/about' -) - -warmUnfurlURLs=( - '/' - '/mining' - '/lightning' -) - -warmURLs=( +warmCommonURLs=( '/api/v1/blocks' '/api/v1/statistics/2h' '/api/v1/statistics/24h' @@ -51,6 +24,9 @@ warmURLs=( '/api/v1/statistics/3y' '/api/v1/statistics/4y' '/api/v1/statistics/all' +) + +warmMiningURLs=( '/api/v1/mining/pools/24h' '/api/v1/mining/pools/3d' '/api/v1/mining/pools/1w' @@ -114,6 +90,9 @@ warmURLs=( '/api/v1/mining/difficulty-adjustments/2y' '/api/v1/mining/difficulty-adjustments/3y' '/api/v1/mining/difficulty-adjustments/all' +) + +warmLightningURLs=( '/api/v1/lightning/channels-geo?style=widget' '/api/v1/lightning/channels-geo?style=graph' '/api/v1/lightning/statistics/latest' @@ -153,43 +132,49 @@ warmURLs=( '/api/v1/lightning/nodes/rankings/age' ) -echo "waiting for mempool backend to start..." +echo "[*] Wait 60s for mempool backend to start..." sleep 60 while true do - echo "starting warm cache cycle..." + echo "[*] Starting warm cache cycle..." + date - for url in $warmSlurpURLs + for url in $warmCommonURLs do - warmSlurp "https://${hostname}${url}" - sleep $delay # delay between queries to not DoS unfurler + warm "http://${hostnameBitcoin}${url}" + warm "http://${hostnameBitcoin}/testnet${url}" + warm "http://${hostnameBitcoin}/testnet4${url}" + warm "http://${hostnameBitcoin}/signet${url}" + warm "http://${hostnameLiquid}${url}" + warm "http://${hostnameLiquid}/testnet${url}" done - for url in $warmUnfurlURLs + for url in $warmMiningURLs do - warmUnfurl "https://${hostname}${url}" - sleep $delay # delay between queries to not DoS unfurler + warm "http://${hostnameBitcoin}${url}" + warm "http://${hostnameBitcoin}/testnet${url}" + warm "http://${hostnameBitcoin}/testnet4${url}" + warm "http://${hostnameBitcoin}/signet${url}" done - for url in $warmURLs + for url in $warmLightningURLs do - warm "https://${hostname}${url}" - warm "https://${hostname}/testnet${url}" - warm "https://${hostname}/testnet4${url}" - warm "https://${hostname}/signet${url}" - sleep $delay # delay between queries to not DoS mariadb + warm "http://${hostnameBitcoin}${url}" + warm "http://${hostnameBitcoin}/testnet${url}" + warm "http://${hostnameBitcoin}/signet${url}" done + slugs=(`curl -sSL http://${hostnameBitcoin}/api/v1/mining/pools/3y|jq -r -S '(.pools[].slug)'`) for slug in $slugs do - warm "https://${hostname}/api/v1/mining/pool/${slug}" - sleep $delay # delay between queries to not DoS mariadb - warm "https://${hostname}/api/v1/mining/pool/${slug}/hashrate" - sleep $delay # delay between queries to not DoS mariadb - warm "https://${hostname}/api/v1/mining/pool/${slug}/blocks" - sleep $delay # delay between queries to not DoS mariadb + warm "http://${hostnameBitcoin}/api/v1/mining/pool/${slug}" + warm "http://${hostnameBitcoin}/api/v1/mining/pool/${slug}/hashrate" + warm "http://${hostnameBitcoin}/api/v1/mining/pool/${slug}/blocks" done + date + echo "[*] Completed warm cache cycle" + sleep 1 done diff --git a/production/nginx-cache-warmer-ssr b/production/nginx-cache-warmer-ssr index 29ebc9883..e4d89afc2 100755 --- a/production/nginx-cache-warmer-ssr +++ b/production/nginx-cache-warmer-ssr @@ -58,6 +58,12 @@ warmUnfurl() sipURLs=( '/' '/mining' + '/lightning' + '/graphs' + '/docs' + '/docs/faq' + '/docs/api/rest' + '/about' ) unfurlURLs=(