-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathrun_all_services.sh
executable file
·64 lines (51 loc) · 1.7 KB
/
run_all_services.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
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
#!/bin/bash
# Set error handling
set -e
# Create logs directory if it doesn't exist
mkdir -p logs
# Function to run a service
run_service() {
local service_name=$1
local port=$2
local log_file="logs/${service_name}.log"
echo "Starting ${service_name} on port ${port}"
# Run the service with UV workspace package and redirect output to log file
FASTMCP_PORT=${port} uv run \
--package "${service_name}" \
python "${service_name}/src/server.py" \
> "${log_file}" 2>&1 &
# Store the PID
echo $! > "logs/${service_name}.pid"
echo "${service_name} started with PID $(cat "logs/${service_name}.pid")"
}
# Function to stop services
stop_services() {
echo "Stopping all services..."
for service in brokerage_service market_data_service research_service; do
if [ -f "logs/${service}.pid" ]; then
pid=$(cat "logs/${service}.pid")
if kill -0 $pid 2>/dev/null; then
echo "Stopping ${service} (PID: $pid)"
kill $pid
rm "logs/${service}.pid"
fi
fi
done
echo "All services stopped"
exit 0
}
# Set up trap for clean shutdown
trap stop_services SIGINT SIGTERM
# Start all services with different ports
run_service "brokerage_service" 8001
run_service "market_data_service" 8002
run_service "research_service" 8003
echo "All services started. Press Ctrl+C to stop all services."
echo "Check logs/ directory for service output."
echo
echo "Services are running on:"
echo "- Brokerage Service: http://localhost:8001"
echo "- Market Data Service: http://localhost:8002"
echo "- Research Service: http://localhost:8003"
# Wait for all background processes
wait