ppsingh commited on
Commit
653e4d2
·
verified ·
1 Parent(s): 5afef8c

Create entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +38 -0
entrypoint.sh ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ SNAPSHOT_DIR="/data/qdrant_snapshots"
5
+ QDRANT_URL="http://localhost:6333"
6
+
7
+ # Start Qdrant in background first
8
+ /qdrant/qdrant &
9
+ QDRANT_PID=$!
10
+
11
+ # Wait for Qdrant to be ready
12
+ echo "Waiting for Qdrant to start..."
13
+ until curl -sf "$QDRANT_URL/readyz" > /dev/null; do
14
+ sleep 1
15
+ done
16
+ echo "Qdrant ready."
17
+
18
+ # Recover any snapshot not yet loaded
19
+ for SNAPSHOT in "$SNAPSHOT_DIR"/*.snapshot; do
20
+ [ -f "$SNAPSHOT" ] || continue
21
+ COLLECTION=$(basename "$SNAPSHOT" .snapshot)
22
+
23
+ # Check if collection already exists
24
+ EXISTS=$(curl -sf "$QDRANT_URL/collections/$COLLECTION" | python3 -c "import sys,json; print(json.load(sys.stdin)['result']['status'])" 2>/dev/null || echo "missing")
25
+
26
+ if [ "$EXISTS" != "green" ]; then
27
+ echo "Recovering collection: $COLLECTION"
28
+ curl -sf -X POST "$QDRANT_URL/collections/$COLLECTION/snapshots/recover" \
29
+ -H "Content-Type: application/json" \
30
+ -d "{\"location\": \"file://$SNAPSHOT\"}"
31
+ echo "Recovered: $COLLECTION"
32
+ else
33
+ echo "Collection $COLLECTION already exists, skipping."
34
+ fi
35
+ done
36
+
37
+ # Hand control back to Qdrant process
38
+ wait $QDRANT_PID