-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-hexfeed.sh
More file actions
executable file
·92 lines (74 loc) · 2.8 KB
/
start-hexfeed.sh
File metadata and controls
executable file
·92 lines (74 loc) · 2.8 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
#!/bin/bash
################################################################################
# HexFeed Application Startup Script
#
# This script provides a comprehensive startup procedure for the HexFeed
# Java Feed System Service with dependency checking and proper sequencing.
#
# Author: AI Assistant
# Date: October 21, 2025
################################################################################
set -e
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${GREEN}================================${NC}"
echo -e "${GREEN}HexFeed Application Startup${NC}"
echo -e "${GREEN}================================${NC}\n"
# Function to check if a port is open
check_port() {
local service=$1
local port=$2
echo -e "${YELLOW}Checking $service on port $port...${NC}"
if nc -z localhost $port 2>/dev/null; then
echo -e "${GREEN}✓ $service is running${NC}"
return 0
else
echo -e "${RED}✗ $service is not running${NC}"
return 1
fi
}
# Step 1: Check Docker services
echo -e "${YELLOW}Step 1: Checking Docker services...${NC}"
if ! docker ps > /dev/null 2>&1; then
echo -e "${RED}Docker is not running. Please start Docker first.${NC}"
exit 1
fi
# Step 2: Start required services
echo -e "\n${YELLOW}Step 2: Starting required services...${NC}"
echo -e "${YELLOW}Starting PostgreSQL, Redis, and Kafka...${NC}"
docker-compose up -d postgres redis kafka 2>&1 | grep -v "version.*obsolete"
echo -e "${YELLOW}Waiting for services to be ready (15 seconds)...${NC}"
sleep 15
# Step 3: Verify services
echo -e "\n${YELLOW}Step 3: Verifying service connectivity...${NC}"
SERVICES_OK=true
check_port "PostgreSQL" 5432 || SERVICES_OK=false
check_port "Redis" 6379 || SERVICES_OK=false
check_port "Kafka" 9092 || SERVICES_OK=false
if [ "$SERVICES_OK" = false ]; then
echo -e "\n${RED}Some services are not ready. Please check Docker logs:${NC}"
echo -e "${YELLOW} docker-compose logs postgres${NC}"
echo -e "${YELLOW} docker-compose logs redis${NC}"
echo -e "${YELLOW} docker-compose logs kafka${NC}"
exit 1
fi
# Step 4: Build application
echo -e "\n${YELLOW}Step 4: Building application...${NC}"
cd hexfeed-backend
mvn clean install -DskipTests
if [ $? -ne 0 ]; then
echo -e "${RED}Build failed. Please check the errors above.${NC}"
exit 1
fi
# Step 5: Start application
echo -e "\n${YELLOW}Step 5: Starting HexFeed application...${NC}"
echo -e "${GREEN}Application will start with profile: dev${NC}"
echo -e "${YELLOW}Logs will be written to: logs/hexfeed-backend.log${NC}"
echo -e "${YELLOW}Press Ctrl+C to stop the application${NC}\n"
# Run the application
mvn spring-boot:run -Dspring-boot.run.profiles=dev
# Note: This line only executes if the app is stopped
echo -e "\n${YELLOW}Application stopped.${NC}"