From c24847ec1846040e81e3afb04bbcb05bb44e6e97 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 10 Apr 2026 00:18:59 +0400 Subject: [PATCH] fix --- apps/monitor/src/runner.rs | 1 + apps/web/src/views/detail.ejs | 1 + deploy.sh | 56 ++++++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/apps/monitor/src/runner.rs b/apps/monitor/src/runner.rs index c32eeb0..a13223a 100644 --- a/apps/monitor/src/runner.rs +++ b/apps/monitor/src/runner.rs @@ -203,6 +203,7 @@ async fn run_check(client: &reqwest::Client, monitor: &Monitor, scheduled_at: Op error: Some(e.clone()), cert_expiry_days: None, cert_issuer: None, + response_size: None, meta: None, region: Some(region.to_string()), run_id: Some(run_id.to_string()), diff --git a/apps/web/src/views/detail.ejs b/apps/web/src/views/detail.ejs index de01db0..847ad7e 100644 --- a/apps/web/src/views/detail.ejs +++ b/apps/web/src/views/detail.ejs @@ -373,6 +373,7 @@ if (ping.cert_expiry_days != null) html += `
Cert expiry
${ping.cert_expiry_days} days
`; if (ping.cert_issuer) html += `
Cert issuer
${escapeHtml(ping.cert_issuer)}
`; if (ping.response_size != null) html += `
Response size
${ping.response_size >= 1024 ? (ping.response_size / 1024).toFixed(1) + ' KB' : ping.response_size + ' B'}
`; + if (ping.important) html += `
Important
Yes
`; html += ''; // Error diff --git a/deploy.sh b/deploy.sh index 3e26d28..8fceba9 100755 --- a/deploy.sh +++ b/deploy.sh @@ -31,7 +31,7 @@ nuke_db() { fi echo "[nuke-db] Dropping all tables on database-eu-central..." $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" REMOTE echo "[nuke-db] Done. Tables will be recreated on next API/web restart." @@ -112,13 +112,67 @@ REMOTE 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" if [ $# -eq 0 ]; then 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)" exit 1 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() { echo "[sync] Syncing time on all servers..." ALL_HOSTS=("$DB_HOST" "$API_HOST" "$WEB_HOST" "${MONITOR_HOSTS[@]}")