-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.sh
More file actions
executable file
·146 lines (121 loc) · 4.25 KB
/
platform.sh
File metadata and controls
executable file
·146 lines (121 loc) · 4.25 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
#!/bin/bash
# ==============================================================================
# platform.sh — AgenticXRAG Platform Orchestrator
# ==============================================================================
#
# DESCRIPTION:
# Top-level entry point that orchestrates the full AgenticXRAG platform stack.
# It sequentially runs two layers in order:
#
# 1. Infrastructure → infra/infra.sh
# • RabbitMQ (message broker)
# • Qdrant (vector database)
#
# 2. Services → services/services.sh
# • FastEmbed (sparse + colbert embedding service)
# • HF (dense HuggingFace embedding service)
#
# USAGE:
# ./platform.sh [ACTION]
#
# ACTIONS:
# start Start all containers across every layer.
# Skips containers that are already running.
#
# stop Gracefully stop all running containers.
# Does NOT remove containers, volumes, or images.
#
# restart Stop then start all containers.
# Always performs a full stop → start cycle.
#
# smart-restart (DEFAULT) Intelligent restart.
# If a container is already running → stop it first.
# If a container is stopped → start it directly.
# Fastest way to apply config changes without a full teardown.
#
# status Print the current status of all containers in every layer.
# Equivalent to running `docker compose ps` in each service dir.
#
# clean ⚠️ DESTRUCTIVE — remove containers, volumes, and images.
# Runs `docker compose down -v --rmi all` + `docker system prune`.
# Use to fully reset the environment (data will be lost).
#
# EXAMPLES:
# ./platform.sh # smart-restart (default)
# ./platform.sh start # start the full stack
# ./platform.sh stop # stop the full stack
# ./platform.sh restart # full stop → start cycle
# ./platform.sh status # show container statuses
# ./platform.sh clean # nuke everything and start fresh
#
# LOGS:
# Platform-level log → logs/platform.log
# Each layer writes its own log inside its directory.
#
# AUTHOR:
# Bajrang Chapola
# ==============================================================================
set -e
# --------------------------------------------------
# Base Paths
# --------------------------------------------------
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LOG_DIR="$BASE_DIR/logs"
LOG_FILE="$LOG_DIR/platform.log"
mkdir -p "$LOG_DIR"
> "$LOG_FILE"
# --------------------------------------------------
# Load Shared Logging
# --------------------------------------------------
source "$BASE_DIR/common.sh"
# --------------------------------------------------
# Setup
# --------------------------------------------------
ACTION=$1
[ -z "$ACTION" ] && ACTION="smart-restart"
section "🦅 AgenticXRAG Platform - $ACTION"
start_timer
# --------------------------------------------------
# Internal Script Paths
# --------------------------------------------------
INFRA_SCRIPT="$BASE_DIR/infra/infra.sh"
SERVICES_SCRIPT="$BASE_DIR/services/services.sh"
# Validate scripts exist
for SCRIPT in "$INFRA_SCRIPT" "$SERVICES_SCRIPT"
do
if [ ! -f "$SCRIPT" ]; then
error "Missing script: $SCRIPT"
exit 1
fi
done
# --------------------------------------------------
# Layer Runner
# --------------------------------------------------
run_layer() {
NAME=$1
SCRIPT=$2
divider
highlight "⚙️ Running $NAME Layer"
bash "$SCRIPT" "$ACTION"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
error "$NAME Layer FAILED"
divider
exit 1
else
success "$NAME Layer completed successfully"
fi
}
# --------------------------------------------------
# Execution Order
# --------------------------------------------------
run_layer "Infrastructure" "$INFRA_SCRIPT"
run_layer "Services" "$SERVICES_SCRIPT"
# --------------------------------------------------
# Finish
# --------------------------------------------------
TOTAL_TIME=$(end_timer)
divider
success "🦅 AgenticXRAG Platform '$ACTION' completed successfully"
info "Total execution time: ${TOTAL_TIME}s"
divider