-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-services.sh
More file actions
executable file
·67 lines (58 loc) · 1.72 KB
/
run-services.sh
File metadata and controls
executable file
·67 lines (58 loc) · 1.72 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
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}=== GameHub Services Launcher ===${NC}"
# Проверка и запуск PostgreSQL
echo -e "${YELLOW}Checking PostgreSQL...${NC}"
if ! docker ps | grep -q gamehub_postgres; then
echo "Starting PostgreSQL container..."
docker-compose up -d
echo "Waiting for PostgreSQL to be ready..."
sleep 5
else
echo "PostgreSQL is already running"
fi
# Функция для запуска сервиса в новом терминале
run_service() {
local service_name=$1
local port=$2
echo -e "${GREEN}Starting $service_name on port $port...${NC}"
# Для macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
osascript -e "tell app \"Terminal\" to do script \"cd '$(pwd)' && cargo run -p $service_name\""
else
echo -e "${RED}Cannot detect terminal. Please run manually:${NC}"
echo "cargo run -p $service_name"
fi
}
echo -e "${YELLOW}Choose an option:${NC}"
echo "1) Start User Service only (port 50051)"
echo "2) Start Game Service only (port 50052)"
echo "3) Start both services"
echo "4) Exit"
read -p "Enter your choice (1-4): " choice
case $choice in
1)
run_service "user-service" "50051"
;;
2)
run_service "game-service" "50052"
;;
3)
run_service "user-service" "50051"
sleep 2
run_service "game-service" "50052"
;;
4)
echo "Exiting..."
exit 0
;;
*)
echo -e "${RED}Invalid choice${NC}"
exit 1
;;
esac
echo -e "${GREEN}Services are starting...${NC}"
echo -e "${YELLOW}User Service:${NC} localhost:50051"
echo -e "${YELLOW}Game Service:${NC} localhost:50052"