Files

38 lines
1.4 KiB
Bash

#!/usr/bin/env bash
# Brings up QuestDB 10.0.1, InfluxDB 3 Core 3.12.0 and TimescaleDB 2.25.1
# (PG17), creates the InfluxDB 3 database + admin token, and exports
# INFLUXDB3_TOKEN for the test run. Source this script, don't execute it:
# source scripts/services-up.sh
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
docker compose up -d
echo "waiting for InfluxDB 3 Core..."
until curl -sf http://localhost:8181/health >/dev/null 2>&1 || curl -s http://localhost:8181/health | grep -q error; do
sleep 1
done
# create (or reuse) an admin token - regenerating is fine for a local sandbox
TOKEN_OUTPUT=$(docker exec time-series-influxdb3-1 influxdb3 create token --admin 2>&1 || true)
export INFLUXDB3_TOKEN=$(echo "$TOKEN_OUTPUT" | grep -oP '(?<=Token: )\S+' || true)
if [ -z "${INFLUXDB3_TOKEN:-}" ]; then
echo "could not parse a fresh token (one may already exist) - set INFLUXDB3_TOKEN manually" >&2
else
docker exec time-series-influxdb3-1 influxdb3 create database sensors --token "$INFLUXDB3_TOKEN" 2>&1 || true
echo "INFLUXDB3_TOKEN exported for this shell."
fi
echo "waiting for TimescaleDB..."
until PGPASSWORD=postgres psql -h localhost -p 5433 -U postgres -d sensors -c '\q' 2>/dev/null; do
sleep 1
done
echo "waiting for QuestDB..."
until PGPASSWORD=quest psql -h localhost -p 8812 -U admin -d qdb -c '\q' 2>/dev/null; do
sleep 1
done
echo "all three engines are up."