#!/bin/bash # Ramp the listmonk-hc hourly send cap in lockstep with the healthcare IP warmup. # # The HEALTHCARE HOT stream sends from fresh dedicated IPs (.107/.108/.109), so # even though institutional B2B mail tolerates far more volume than consumer # cold mail, we still warm these IPs before hitting the 10k/day ceiling. This is # the hc analogue of /usr/local/bin/pw-listmonk-rampcap, driven off a SEPARATE # warmup stamp (/etc/postfix/hc-warmup-start) and writing a SEPARATE Listmonk # DB (listmonk_hc), so the trucking ramp/cap and the healthcare ramp/cap are # fully independent. # # Steady-state target (institutional, 3 IPs): # day 0-1 : ~1,000/day -> 100/h # day 2-4 : ~3,000/day -> 300/h # day 5-9 : ~6,000/day -> 600/h # day 10+ : ~10,000/day -> 1000/h (the chosen ceiling) set -euo pipefail STATE=/etc/postfix/hc-warmup-start COMPOSE_DIR=/opt/performancewest DB=listmonk_hc PGPASSWORD=${DB_PASSWORD:-pw_dev_2026} [ -f "$STATE" ] || { echo "no hc warmup stamp ($STATE); run hc_stream_setup.sh first"; exit 1; } START=$(cat "$STATE"); NOW=$(date +%s); DAYS=$(( (NOW - START) / 86400 )) if [ "$DAYS" -le 1 ]; then RATE=100 elif [ "$DAYS" -le 4 ]; then RATE=300 elif [ "$DAYS" -le 9 ]; then RATE=600 else RATE=1000; fi cd "$COMPOSE_DIR" psql() { PGPASSWORD=$PGPASSWORD docker compose exec -T -e PGPASSWORD=$PGPASSWORD api-postgres \ psql -U pw -d "$DB" -tAc "$1"; } CUR=$(psql "SELECT value FROM settings WHERE key='app.message_sliding_window_rate';" 2>/dev/null || echo "") if [ "$CUR" != "$RATE" ]; then psql "UPDATE settings SET value='$RATE' WHERE key='app.message_sliding_window_rate'; UPDATE settings SET value='\"1h\"' WHERE key='app.message_sliding_window_duration'; UPDATE settings SET value='true' WHERE key='app.message_sliding_window';" >/dev/null docker compose restart listmonk-hc >/dev/null 2>&1 || true logger -t pw-hc-rampcap "day $DAYS -> listmonk-hc cap ${RATE}/h (was ${CUR}/h)" echo "$(date '+%F %T') hc-rampcap: day=$DAYS cap=${RATE}/h (changed from ${CUR}/h, listmonk-hc restarted)" else echo "$(date '+%F %T') hc-rampcap: day=$DAYS cap=${RATE}/h (no change)" fi