This commit is contained in:
nate 2026-04-10 00:18:59 +04:00
parent 60b88dd4d4
commit c24847ec18
3 changed files with 57 additions and 1 deletions

View File

@ -203,6 +203,7 @@ async fn run_check(client: &reqwest::Client, monitor: &Monitor, scheduled_at: Op
error: Some(e.clone()), error: Some(e.clone()),
cert_expiry_days: None, cert_expiry_days: None,
cert_issuer: None, cert_issuer: None,
response_size: None,
meta: None, meta: None,
region: Some(region.to_string()), region: Some(region.to_string()),
run_id: Some(run_id.to_string()), run_id: Some(run_id.to_string()),

View File

@ -373,6 +373,7 @@
if (ping.cert_expiry_days != null) html += `<div class="text-gray-500">Cert expiry</div><div class="text-gray-300">${ping.cert_expiry_days} days</div>`; if (ping.cert_expiry_days != null) html += `<div class="text-gray-500">Cert expiry</div><div class="text-gray-300">${ping.cert_expiry_days} days</div>`;
if (ping.cert_issuer) html += `<div class="text-gray-500">Cert issuer</div><div class="text-gray-300">${escapeHtml(ping.cert_issuer)}</div>`; if (ping.cert_issuer) html += `<div class="text-gray-500">Cert issuer</div><div class="text-gray-300">${escapeHtml(ping.cert_issuer)}</div>`;
if (ping.response_size != null) html += `<div class="text-gray-500">Response size</div><div class="text-gray-300">${ping.response_size >= 1024 ? (ping.response_size / 1024).toFixed(1) + ' KB' : ping.response_size + ' B'}</div>`; if (ping.response_size != null) html += `<div class="text-gray-500">Response size</div><div class="text-gray-300">${ping.response_size >= 1024 ? (ping.response_size / 1024).toFixed(1) + ' KB' : ping.response_size + ' B'}</div>`;
if (ping.important) html += `<div class="text-gray-500">Important</div><div class="text-yellow-400">Yes</div>`;
html += '</div>'; html += '</div>';
// Error // Error

View File

@ -31,7 +31,7 @@ nuke_db() {
fi fi
echo "[nuke-db] Dropping all tables on database-eu-central..." echo "[nuke-db] Dropping all tables on database-eu-central..."
$SSH $DB_HOST bash << 'REMOTE' $SSH $DB_HOST bash << 'REMOTE'
sudo -u postgres psql -d pingql -c "DROP TABLE IF EXISTS payment_txs, ping_bodies, payments, pings, api_keys, monitors, accounts CASCADE;" sudo -u postgres psql -d pingql -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public; GRANT ALL ON SCHEMA public TO public;"
echo "All tables dropped" echo "All tables dropped"
REMOTE REMOTE
echo "[nuke-db] Done. Tables will be recreated on next API/web restart." echo "[nuke-db] Done. Tables will be recreated on next API/web restart."
@ -112,13 +112,67 @@ REMOTE
echo "[monitor] All monitors deployed" echo "[monitor] All monitors deployed"
} }
stop_app() {
local app="$1"
case "$app" in
api)
echo "[stop] Stopping pingql-api on api-eu-central..."
$SSH $API_HOST "systemctl stop pingql-api && echo 'pingql-api stopped'"
;;
pay)
echo "[stop] Stopping pingql-pay on api-eu-central..."
$SSH $API_HOST "systemctl stop pingql-pay && echo 'pingql-pay stopped'"
;;
web)
echo "[stop] Stopping pingql-web on web-eu-central..."
$SSH $WEB_HOST "systemctl stop pingql-web && echo 'pingql-web stopped'"
;;
status)
echo "[stop] Stopping pingql-status on web-eu-central..."
$SSH $WEB_HOST "systemctl stop pingql-status && echo 'pingql-status stopped'"
;;
monitor)
echo "[stop] Stopping monitors on all hosts..."
for host in "${MONITOR_HOSTS[@]}"; do
($SSH "$host" 'systemctl stop pingql-monitor && echo "pingql-monitor stopped on $(hostname)"') &
done
wait
;;
all)
stop_app api; stop_app pay; stop_app web; stop_app status; stop_app monitor
;;
*)
echo "Unknown app: $app (valid: api, pay, web, status, monitor, all)"
return 1
;;
esac
}
# Parse args — supports both "./deploy.sh web api" and "./deploy.sh web,api" # Parse args — supports both "./deploy.sh web api" and "./deploy.sh web,api"
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
echo "Usage: $0 [web|api|pay|status|monitor|db|all] [...]" echo "Usage: $0 [web|api|pay|status|monitor|db|all] [...]"
echo " $0 stop [api|pay|web|status|monitor|all]"
echo " $0 web,api,status (comma-separated)" echo " $0 web,api,status (comma-separated)"
exit 1 exit 1
fi fi
# Handle "stop" action
if [ "$1" = "stop" ]; then
shift
if [ $# -eq 0 ]; then
echo "Usage: $0 stop [api|pay|web|status|monitor|all]"
exit 1
fi
for arg in "$@"; do
IFS=',' read -ra targets <<< "$arg"
for target in "${targets[@]}"; do
stop_app "$target"
done
done
echo "Stop complete."
exit 0
fi
sync_time() { sync_time() {
echo "[sync] Syncing time on all servers..." echo "[sync] Syncing time on all servers..."
ALL_HOSTS=("$DB_HOST" "$API_HOST" "$WEB_HOST" "${MONITOR_HOSTS[@]}") ALL_HOSTS=("$DB_HOST" "$API_HOST" "$WEB_HOST" "${MONITOR_HOSTS[@]}")