-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch.sh
More file actions
executable file
·182 lines (147 loc) · 4.71 KB
/
Copy pathlaunch.sh
File metadata and controls
executable file
·182 lines (147 loc) · 4.71 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash
###########################################
# OmniMemory Full Service Launcher
# Starts infrastructure + all microservices
###########################################
set -e
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG_DIR="$HOME/.omnimemory/logs"
PID_FILE="$HOME/.omnimemory/pids"
# Create directories
mkdir -p "$LOG_DIR"
# Service ports
EMBEDDING_PORT=8000
COMPRESSION_PORT=8001
PROCEDURAL_PORT=8002
METRICS_PORT=8004
###########################################
# Helper Functions
###########################################
print_banner() {
echo -e "${BLUE}"
echo "╔════════════════════════════════════════╗"
echo "║ OmniMemory Full Service Launcher ║"
echo "╚════════════════════════════════════════╝"
echo -e "${NC}"
}
print_status() {
local status=$1
local message=$2
if [ "$status" = "ok" ]; then
echo -e "${GREEN}✓${NC} $message"
elif [ "$status" = "error" ]; then
echo -e "${RED}✗${NC} $message"
elif [ "$status" = "info" ]; then
echo -e "${BLUE}ℹ${NC} $message"
else
echo -e "${YELLOW}⚠${NC} $message"
fi
}
check_port() {
local port=$1
lsof -i :$port >/dev/null 2>&1
}
wait_for_service() {
local name=$1
local url=$2
local max_attempts=30
local attempt=0
print_status "info" "Waiting for $name..."
while [ $attempt -lt $max_attempts ]; do
if curl -s "$url/health" >/dev/null 2>&1; then
print_status "ok" "$name is ready"
return 0
fi
sleep 1
((attempt++))
done
print_status "error" "$name failed to start"
return 1
}
start_python_service() {
local name=$1
local dir=$2
local port=$3
if check_port $port; then
print_status "warn" "$name already running on port $port"
return 0
fi
print_status "info" "Starting $name..."
cd "$SCRIPT_DIR/$dir"
if [ ! -f "requirements.txt" ]; then
print_status "error" "Directory $dir not found or missing requirements.txt"
return 1
fi
# Start service in background
nohup python -m src.$(basename $dir | sed 's/omnimemory-//' | sed 's/-/_/g')_server \
> "$LOG_DIR/$(basename $dir).log" 2>&1 &
local pid=$!
echo "$pid:$name:$port" >> "$PID_FILE"
print_status "ok" "$name started (PID: $pid)"
cd "$SCRIPT_DIR"
}
###########################################
# Main Execution
###########################################
print_banner
# Step 1: Check Docker infrastructure
print_status "info" "Checking Docker infrastructure..."
if ! docker info > /dev/null 2>&1; then
print_status "error" "Docker is not running. Please start Docker Desktop."
exit 1
fi
if ! docker-compose ps | grep -q "Up"; then
print_status "warn" "Docker services not running. Starting infrastructure..."
./start.sh
sleep 5
fi
print_status "ok" "Docker infrastructure is running"
# Step 2: Start Python microservices
echo ""
print_status "info" "Starting Python microservices..."
echo ""
# Clear old PID file
> "$PID_FILE"
# Start services in dependency order
start_python_service "Embeddings Service" "omnimemory-embeddings" $EMBEDDING_PORT
sleep 2
wait_for_service "Embeddings" "http://localhost:$EMBEDDING_PORT"
start_python_service "Compression Service" "omnimemory-compression" $COMPRESSION_PORT
sleep 2
wait_for_service "Compression" "http://localhost:$COMPRESSION_PORT"
start_python_service "Procedural Service" "omnimemory-procedural" $PROCEDURAL_PORT
sleep 2
wait_for_service "Procedural" "http://localhost:$PROCEDURAL_PORT"
start_python_service "Metrics Service" "omnimemory-metrics-service" $METRICS_PORT
sleep 2
wait_for_service "Metrics" "http://localhost:$METRICS_PORT"
# Step 3: Summary
echo ""
print_banner
echo -e "${GREEN}✓ OmniMemory is fully operational!${NC}"
echo ""
echo "📊 Service URLs:"
echo " • Embeddings: http://localhost:$EMBEDDING_PORT"
echo " • Compression: http://localhost:$COMPRESSION_PORT"
echo " • Procedural: http://localhost:$PROCEDURAL_PORT"
echo " • Metrics: http://localhost:$METRICS_PORT"
echo ""
echo "🐳 Infrastructure:"
echo " • PostgreSQL: localhost:5432"
echo " • Qdrant: http://localhost:6333"
echo " • Redis: localhost:6379"
echo ""
echo "📝 Useful commands:"
echo " • View logs: tail -f $LOG_DIR/*.log"
echo " • Check status: ./status-all.sh"
echo " • Stop all: ./stop-all.sh"
echo ""
echo "💡 PID file: $PID_FILE"
echo ""