This commit is contained in:
@@ -35,17 +35,34 @@ pip install -r requirements.txt
|
||||
if [ ! -f ".env" ]; then
|
||||
echo -e "${YELLOW}⚠️ .env file not found. Creating from example...${NC}"
|
||||
cp .env.example .env
|
||||
echo -e "${GREEN}✅ .env file created. Please review and update settings.${NC}"
|
||||
|
||||
# Update .env with external PostgreSQL configuration
|
||||
sed -i 's|postgresql+asyncpg://admin:password@localhost:5432/women_safety|postgresql+asyncpg://admin:password@192.168.0.102:5432/women_safety|g' .env
|
||||
echo -e "${GREEN}✅ .env file created and updated with external PostgreSQL configuration.${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ Updating .env with external PostgreSQL configuration...${NC}"
|
||||
sed -i 's|postgresql+asyncpg://admin:password@localhost:5432/women_safety|postgresql+asyncpg://admin:password@192.168.0.102:5432/women_safety|g' .env
|
||||
echo -e "${GREEN}✅ .env file updated with external PostgreSQL configuration.${NC}"
|
||||
fi
|
||||
|
||||
# Start infrastructure services
|
||||
echo "🐳 Starting infrastructure services..."
|
||||
docker compose up -d postgres redis kafka zookeeper
|
||||
docker compose up -d redis kafka zookeeper
|
||||
|
||||
# Wait for services to be ready
|
||||
echo -e "${YELLOW}⏳ Waiting for services to be ready...${NC}"
|
||||
sleep 10
|
||||
|
||||
# Test PostgreSQL connection
|
||||
echo -e "${YELLOW}🔌 Testing PostgreSQL connection (192.168.0.102:5432)...${NC}"
|
||||
if pg_isready -h 192.168.0.102 -p 5432; then
|
||||
echo -e "${GREEN}✅ PostgreSQL connection successful!${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Cannot connect to PostgreSQL. Please check that the server is running.${NC}"
|
||||
echo -e "${RED}❌ Aborting startup.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run database migrations
|
||||
echo -e "${YELLOW}🗃️ Running database migrations...${NC}"
|
||||
alembic upgrade head
|
||||
@@ -106,12 +123,12 @@ cleanup() {
|
||||
echo -e "\n${YELLOW}🛑 Shutting down services...${NC}"
|
||||
|
||||
# Kill all background processes
|
||||
if [ -f "user_service.pid" ]; then kill $(cat user_service.pid) 2>/dev/null && rm user_service.pid; fi
|
||||
if [ -f "emergency_service.pid" ]; then kill $(cat emergency_service.pid) 2>/dev/null && rm emergency_service.pid; fi
|
||||
if [ -f "location_service.pid" ]; then kill $(cat location_service.pid) 2>/dev/null && rm location_service.pid; fi
|
||||
if [ -f "calendar_service.pid" ]; then kill $(cat calendar_service.pid) 2>/dev/null && rm calendar_service.pid; fi
|
||||
if [ -f "notification_service.pid" ]; then kill $(cat notification_service.pid) 2>/dev/null && rm notification_service.pid; fi
|
||||
if [ -f "api_gateway.pid" ]; then kill $(cat api_gateway.pid) 2>/dev/null && rm api_gateway.pid; fi
|
||||
if [ -f "user_service.pid" ]; then kill "$(cat user_service.pid)" 2>/dev/null && rm user_service.pid; fi
|
||||
if [ -f "emergency_service.pid" ]; then kill "$(cat emergency_service.pid)" 2>/dev/null && rm emergency_service.pid; fi
|
||||
if [ -f "location_service.pid" ]; then kill "$(cat location_service.pid)" 2>/dev/null && rm location_service.pid; fi
|
||||
if [ -f "calendar_service.pid" ]; then kill "$(cat calendar_service.pid)" 2>/dev/null && rm calendar_service.pid; fi
|
||||
if [ -f "notification_service.pid" ]; then kill "$(cat notification_service.pid)" 2>/dev/null && rm notification_service.pid; fi
|
||||
if [ -f "api_gateway.pid" ]; then kill "$(cat api_gateway.pid)" 2>/dev/null && rm api_gateway.pid; fi
|
||||
|
||||
echo -e "${GREEN}✅ All services stopped${NC}"
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user