-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·160 lines (137 loc) · 5.36 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·160 lines (137 loc) · 5.36 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
# ==============================================================================
# run.sh — AgenticXRAG Full-Stack Runner
# ==============================================================================
#
# DESCRIPTION:
# Master entry point that brings up the complete AgenticXRAG stack by
# orchestrating two sub-scripts in the correct dependency order:
#
# ┌─────────────────────────────────────────────────────────┐
# │ Startup order (start / restart / smart-restart) │
# │ │
# │ 1. platform.sh → Infrastructure + Services layer │
# │ • RabbitMQ (message broker) │
# │ • Qdrant (vector database) │
# │ • FastEmbed (sparse + ColBERT embeddings) │
# │ • HF (dense HF embeddings) │
# │ │
# │ 2. agenticxrag.sh → Application (Core) layer │
# │ • AgenticXRAG API (FastAPI + Uvicorn) │
# └─────────────────────────────────────────────────────────┘
#
# Shutdown order is reversed — Core stops before Platform:
# stop / clean: agenticxrag.sh → platform.sh
#
# USAGE:
# ./run.sh [ACTION]
#
# ACTIONS:
# start Start the full stack (Platform → Core).
# Safe to call when services are already running;
# skips containers that do not need restarting.
#
# stop Gracefully stop the full stack (Core → Platform).
# Containers are stopped but NOT removed.
# Volumes and images are preserved.
#
# restart Full stop → start cycle for the entire stack.
# Equivalent to `stop` followed by `start`.
#
# smart-restart (DEFAULT) Intelligent restart — only restarts
# containers that are currently running; starts
# stopped ones directly. Faster than a full restart.
#
# status Show the live status of every container in
# all layers (Platform + Core).
# Read-only; no containers are modified.
#
# clean ⚠️ DESTRUCTIVE — tear down all containers,
# volumes, and images across every layer.
# Runs in reverse order (Core → Platform).
# All persisted data (Qdrant, RabbitMQ) will be lost.
#
# EXAMPLES:
# ./run.sh # smart-restart (default — safest choice)
# ./run.sh start # cold-start the entire stack
# ./run.sh stop # gracefully stop everything
# ./run.sh restart # full cycle restart
# ./run.sh status # view container health
# ./run.sh clean # ⚠️ full teardown (data loss)
#
# LOGS:
# Master log → logs/agenticxrag.log
# Each sub-script appends its own output to the same log file.
#
# AUTHOR:
# Bajrang Chapola
# ==============================================================================
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LOG_DIR="$BASE_DIR/logs"
LOG_FILE="$LOG_DIR/agenticxrag.log"
mkdir -p "$LOG_DIR"
> "$LOG_FILE"
timestamp() {
date "+%Y-%m-%d %H:%M:%S"
}
log() {
echo -e "[$(timestamp)] $1" | tee -a "$LOG_FILE"
}
info() { log "\033[1;34m[INFO]\033[0m $1"; }
success() { log "\033[1;32m[SUCCESS]\033[0m $1"; }
error() { log "\033[1;31m[ERROR]\033[0m $1"; }
ACTION=$1
if [ -z "$ACTION" ]; then
ACTION="smart-restart"
info "No action provided → Smart Restart Full AgenticXRAG"
else
info "AgenticXRAG started with action: $ACTION"
fi
echo "---------------------------------------" | tee -a "$LOG_FILE"
PLATFORM_SCRIPT="$BASE_DIR/platform.sh"
CORE_SCRIPT="$BASE_DIR/agenticxrag.sh"
for SCRIPT in "$PLATFORM_SCRIPT" "$CORE_SCRIPT"
do
if [ ! -f "$SCRIPT" ]; then
error "Missing required script: $SCRIPT"
exit 1
fi
done
run_script() {
NAME=$1
SCRIPT=$2
info "Running $NAME..."
bash "$SCRIPT" "$ACTION" >> "$LOG_FILE" 2>&1
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
error "$NAME failed (exit code $EXIT_CODE)"
exit 1
fi
success "$NAME completed successfully"
}
# ---------------------------
# Action Routing Logic
# ---------------------------
case $ACTION in
start|restart|smart-restart|status)
# Start platform first, then core
run_script "AgenticXRAG Platform" "$PLATFORM_SCRIPT"
run_script "AgenticXRAG Core" "$CORE_SCRIPT"
if [[ "$ACTION" != "status" ]]; then
echo "---------------------------------------" | tee -a "$LOG_FILE"
success "🦅 Full AgenticXRAG Platform is UP and Running"
fi
;;
stop|clean)
# Stop/clean core first, then platform
run_script "AgenticXRAG Core" "$CORE_SCRIPT"
run_script "AgenticXRAG Platform" "$PLATFORM_SCRIPT"
echo "---------------------------------------" | tee -a "$LOG_FILE"
success "🧹 Full AgenticXRAG Platform cleaned/stopped successfully"
;;
*)
error "Invalid action: $ACTION"
echo "Usage: ./agenticxrag.sh [start|stop|restart|status|clean]"
exit 1
;;
esac