diff --git a/apps/web/src/dashboard/app.js b/apps/web/src/dashboard/app.js index 3a832e6..2b2bbc7 100644 --- a/apps/web/src/dashboard/app.js +++ b/apps/web/src/dashboard/app.js @@ -82,7 +82,13 @@ function watchAccount(onPing) { buf = lines.pop() ?? ''; for (const line of lines) { if (line.startsWith('data: ')) { - try { onPing(JSON.parse(line.slice(6))); } catch {} + try { + const ping = JSON.parse(line.slice(6)); + if (ping.checked_at && new Date(ping.checked_at).getTime() > Date.now()) { + ping.checked_at = new Date().toISOString(); + } + onPing(ping); + } catch {} } } } diff --git a/deploy.sh b/deploy.sh index 978ae81..bfd8f87 100755 --- a/deploy.sh +++ b/deploy.sh @@ -102,6 +102,18 @@ if [ $# -eq 0 ]; then exit 1 fi +sync_time() { + echo "[sync] Syncing time on all servers..." + ALL_HOSTS=("$DB_HOST" "$API_HOST" "$WEB_HOST" "${MONITOR_HOSTS[@]}") + for host in "${ALL_HOSTS[@]}"; do + ( + $SSH "$host" "chronyc makestep 2>/dev/null || ntpdate -s pool.ntp.org 2>/dev/null || timedatectl set-ntp true 2>/dev/null; echo \"$(hostname 2>/dev/null || echo $host): $(date -u +%H:%M:%S.%N)\"" + ) & + done + wait + echo "[sync] All servers synced" +} + deploy_target() { case "$1" in db) deploy_db ;; @@ -110,8 +122,9 @@ deploy_target() { web) deploy_web ;; monitor) deploy_monitor ;; nuke-db) nuke_db ;; + sync) sync_time ;; all) deploy_db; deploy_api; deploy_pay; deploy_web; deploy_monitor ;; - *) echo "Unknown target: $1 (valid: web, api, pay, monitor, db, nuke-db, all)"; exit 1 ;; + *) echo "Unknown target: $1 (valid: web, api, pay, monitor, db, nuke-db, sync, all)"; exit 1 ;; esac }