#!/usr/bin/env bash # author: simon-pierre boucher # Deploy Tendril to the production node (ยง16.4). Idempotent: rsync source, # install, build, (re)start PM2, then smoke-test through the public URL. set -euo pipefail NODE="${TENDRIL_NODE:-M3U96a}" DIR="${TENDRIL_DIR:-apps/tendril}" PORT="${TENDRIL_PORT:-8092}" PUBLIC_URL="${TENDRIL_PUBLIC_URL:-https://www.ten-dril.com}" HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" echo "==> rsync source to ${NODE}:${DIR}" ssh "$NODE" "mkdir -p ~/${DIR}" rsync -az --delete \ --exclude node_modules --exclude '.git' --exclude 'dist' \ --exclude '*.tsbuildinfo' --exclude 'coverage' --exclude 'blobs' \ "$HERE"/ "${NODE}:${DIR}/" echo "==> install + build on ${NODE}" ssh "$NODE" "cd ~/${DIR} && pnpm install --frozen-lockfile && pnpm build" echo "==> (re)start PM2" ssh "$NODE" "cd ~/${DIR} && TENDRIL_DIR=\$HOME/${DIR} TENDRIL_PORT=${PORT} pm2 startOrReload deploy/ecosystem.config.cjs --update-env && pm2 save" echo "==> local health" ssh "$NODE" "for i in \$(seq 1 40); do curl -sf http://127.0.0.1:${PORT}/healthz >/dev/null && { echo healthy; break; }; sleep 0.5; done" echo "==> smoke test through ${PUBLIC_URL}" "$HERE/scripts/health.sh" "$PUBLIC_URL" echo "==> done"