← back to Db Saturation Fix
1-immediate-relief.sh
23 lines
#!/usr/bin/env bash
# IMMEDIATE RELIEF — run ON Kamatera (45.61.58.125) as root.
# Stops the *errored* crash-loopers that churn/hold dw_admin connections for no benefit.
# Reversible: `pm2 start <name>` brings any of them back. Review before running.
set -uo pipefail
echo "== current pm2 crash-loopers (errored or very high restarts) =="
pm2 jlist | node -e 'let d="";process.stdin.on("data",c=>d+=c).on("end",()=>{
JSON.parse(d).map(p=>({n:p.name,r:p.pm2_env.restart_time,s:p.pm2_env.status}))
.filter(p=>p.s==="errored"||p.r>500).sort((a,b)=>b.r-a.r)
.forEach(p=>console.log(` ${p.n} restarts=${p.r} ${p.s}`));}'
echo
echo "== SAFE stop: momentum-crawler is ERRORED (4023 restarts, doing nothing) =="
read -p "Stop momentum-crawler? [y/N] " a; [ "$a" = y ] && pm2 stop momentum-crawler && echo "stopped."
# koroseal-quote-api is ONLINE (2225 restarts) — it may be load-bearing. Do NOT blind-stop.
# Inspect first: pm2 logs koroseal-quote-api --lines 50 (fix the restart cause, don't just kill)
echo
echo "== connections after =="
ps -C postgres -o cmd= | grep -c "postgres:"