Test env NATS cluster cut-over

This commit is contained in:
George Lambert 2026-09-11 23:59:41 -04:00
commit 3eaad04d7b
14 changed files with 367 additions and 0 deletions

34
scripts/ensure-streams.sh Executable file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Create product JetStream streams with replicas=3 on the Proxmox cluster.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
# shellcheck disable=SC1091
. "$ROOT/client.env"
export PATH="/usr/sbin:/usr/bin:/bin:/usr/local/bin:$PATH"
VMID="${1:-511}"
sudo pct exec "$VMID" -- bash -lc "
set -e
export DEBIAN_FRONTEND=noninteractive
export PATH=/usr/local/bin:/usr/bin:/bin
export NATS_URL=nats://10.10.10.21:4222
if [[ ! -x /usr/local/bin/nats ]]; then
apt-get install -y --no-install-recommends unzip >/dev/null
curl -fsSL https://github.com/nats-io/natscli/releases/download/v0.1.6/nats-0.1.6-linux-amd64.zip -o /tmp/natscli.zip
rm -rf /tmp/natscli && mkdir -p /tmp/natscli
unzip -o /tmp/natscli.zip -d /tmp/natscli >/dev/null
BIN=\$(find /tmp/natscli -type f -name nats | head -1)
install -m 0755 \"\$BIN\" /usr/local/bin/nats
fi
add() {
local name=\$1 subj=\$2
nats stream info \"\$name\" >/dev/null 2>&1 && return 0
nats stream add \"\$name\" --subjects=\"\$subj\" --replicas=3 --storage=file --retention=limits --discard=old --max-msgs=-1 --max-bytes=-1 --max-age=24h --dupe-window=2m --defaults
}
add ZAPIER_JOBS 'verae.zapier.jobs.watch'
add ZAPIER_EVENTS 'verae.zapier.jobs.events'
add ZAPIER_WEBHOOKS 'verae.zapier.webhooks.deliver'
add ZAPIER_USAGE 'verae.zapier.usage'
add VERAE_ARCHIVE 'verae.archive.>'
nats stream ls
"
echo "streams ready on cluster (replicas=3)"