-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
32 lines (27 loc) · 859 Bytes
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /bin/bash
set -euo pipefail
host="${FLY_MACHINE_ID}.vm.${FLY_APP_NAME}.internal"
# Get current host IP
host_ipv6=$(getent ahostsv6 fly-local-6pn | head -n1 | awk '{print $1}')
if [[ -z "${host_ipv6}" ]]; then
echo "Error: Unable to determine this host's IP address."
exit 1
fi
# Determine seed node
seed=
for i in $(dig +short aaaa "${FLY_APP_NAME}.internal"); do
if [[ "${i}" != "${host_ipv6}" ]]; then
seed="${i}"
break
fi
done
# Start qdrant
if [[ -n "${seed}" ]]; then
# If there are other active devices, use the HostName of one of them.
echo "Bootstrapping new peer..."
./qdrant --bootstrap "http://[${seed}]:6335" --uri "http://${host}:6335"
else
# If there are no other active devices, start normally.
echo "Starting cluster without bootstrap..."
./qdrant --uri "http://${host}:6335"
fi