74 lines
2.2 KiB
Bash
Executable File
74 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck source=common.sh
|
|
source "$SCRIPT_DIR/common.sh"
|
|
|
|
WAIT_FIRST_RUN=1
|
|
TIMEOUT_SECS=""
|
|
|
|
usage() {
|
|
cat <<'USAGE'
|
|
Usage: ./scripts/start.sh [--no-wait-first-run] [--timeout-secs N]
|
|
|
|
Start ours RP. If no successful run exists, wait for the first snapshot to succeed
|
|
before starting metrics, Prometheus and Grafana.
|
|
USAGE
|
|
}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--no-wait-first-run)
|
|
WAIT_FIRST_RUN=0
|
|
shift
|
|
;;
|
|
--timeout-secs)
|
|
TIMEOUT_SECS="$2"
|
|
shift 2
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
die "unknown option: $1"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
load_env
|
|
assert_arch_compatibility
|
|
create_data_dirs
|
|
timeout_secs="${TIMEOUT_SECS:-$FIRST_RUN_WAIT_TIMEOUT_SECS}"
|
|
before_latest="$(latest_run_dir || true)"
|
|
had_success=0
|
|
if has_success_run; then
|
|
had_success=1
|
|
fi
|
|
|
|
log "starting core soak service"
|
|
if [[ -n "${CUSTOM_REPO_NETWORK:-}" ]]; then
|
|
# Custom TAL mode against the stack local test repository: create the soak
|
|
# container without starting it, attach the shared external network first,
|
|
# then start it. This avoids the first snapshot racing the network connect.
|
|
compose_cmd --profile core up -d --no-start ours-rp-soak 2>/dev/null \
|
|
|| compose_cmd --profile core create ours-rp-soak
|
|
soak_container="${COMPOSE_PROJECT_NAME:-ours-rp-package-installer}-soak"
|
|
if ! docker inspect -f '{{json .NetworkSettings.Networks}}' "$soak_container" | grep -q "\"$CUSTOM_REPO_NETWORK\""; then
|
|
log "attaching soak container to custom repo network: $CUSTOM_REPO_NETWORK"
|
|
docker network connect "$CUSTOM_REPO_NETWORK" "$soak_container"
|
|
fi
|
|
compose_cmd --profile core start ours-rp-soak
|
|
else
|
|
compose_cmd --profile core up -d ours-rp-soak
|
|
fi
|
|
|
|
if [[ "$had_success" == "0" && "$WAIT_FIRST_RUN" == "1" ]]; then
|
|
log "no previous successful run found; waiting for first run timeout=${timeout_secs}s"
|
|
wait_for_new_success_run "$before_latest" "$timeout_secs"
|
|
fi
|
|
|
|
log "starting metrics and monitor services"
|
|
compose_cmd --profile sidecar --profile monitor up -d artifact-metrics prometheus grafana
|
|
"$SCRIPT_DIR/status.sh" --brief || true
|