who_need_help/scripts/scale-stack-up.sh

51 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
set -eu
ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
# shellcheck source=scripts/scale-common.sh
. "$ROOT/scripts/scale-common.sh"
scale_load_environment
case "$CPU_REPLAY_CPUSET" in
''|*[!0-9,-]*)
echo "WNH_SCALE_CPUSET must be a Docker cpuset expression." >&2
exit 2
;;
esac
cd "$ROOT"
scale_compose up -d --build --wait --scale web=1 --scale worker=1
COMPOSE_PROJECT_NAME=$LOAD_PROJECT "$ROOT/scripts/verify-realtime-cluster.sh" compose
COMPOSE_PROJECT_NAME=$LOAD_PROJECT "$ROOT/scripts/verify-beam-runtime.sh" compose
deadline=$(( $(date +%s) + LOAD_RESILIENCE_RECOVERY_TIMEOUT_SECONDS ))
status=000
while [ "$(date +%s)" -le "$deadline" ]; do
if ! status=$(
curl --insecure --silent \
--resolve "$LOAD_HOST:$SCALE_HTTPS_PORT:127.0.0.1" \
--output /dev/null \
--write-out '%{http_code}' \
"https://$LOAD_HOST:$SCALE_HTTPS_PORT/healthz/ready"
); then
status=000
fi
[ "$status" = 200 ] && break
sleep "$LOAD_RESILIENCE_PROBE_INTERVAL_SECONDS"
done
if [ "$status" != 200 ]; then
echo "Scale-profile readiness returned HTTP $status instead of 200." >&2
exit 1
fi
curl --fail --silent --show-error --insecure \
--resolve "$LOAD_HOST:$SCALE_HTTPS_PORT:127.0.0.1" \
"https://$LOAD_HOST:$SCALE_HTTPS_PORT/healthz/ready"
printf '\nPersistent scale stack: https://%s:%s\n' "$LOAD_HOST" "$SCALE_HTTPS_PORT"
printf 'Mailpit: http://127.0.0.1:%s\n' "$MAILPIT_PORT"