Files
Hyungi Ahn 550633b89d feat: 3-System 분리 프로젝트 초기 코드 작성
TK-FB(공장관리+신고)와 M-Project(부적합관리)를 3개 독립 시스템으로
분리하기 위한 전체 코드 구조 작성.
- SSO 인증 서비스 (bcrypt + pbkdf2 이중 해시 지원)
- System 1: 공장관리 (TK-FB 기반, 신고 코드 제거)
- System 2: 신고 (TK-FB에서 workIssue 코드 추출)
- System 3: 부적합관리 (M-Project 기반)
- Gateway 포털 (path-based 라우팅)
- 통합 docker-compose.yml 및 배포 스크립트

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 14:40:11 +09:00

98 lines
3.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 색상 정의
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE} API 서버 배포 스크립트${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# 현재 디렉토리 확인
if [ ! -f "package.json" ]; then
echo -e "${RED}❌ 오류: package.json을 찾을 수 없습니다.${NC}"
echo -e "${RED} api.hyungi.net 디렉토리에서 실행해주세요.${NC}"
exit 1
fi
echo -e "${BLUE}📂 현재 디렉토리:${NC} $(pwd)"
echo ""
# 1. Git Pull
echo -e "${YELLOW}1⃣ Git Pull 시작...${NC}"
git pull
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Git Pull 실패${NC}"
exit 1
fi
echo -e "${GREEN}✅ Git Pull 완료${NC}"
echo ""
# 2. NPM Install (package.json 변경 확인)
echo -e "${YELLOW}2⃣ 의존성 확인 중...${NC}"
if git diff HEAD@{1} HEAD --name-only | grep -q "package.json"; then
echo -e "${YELLOW}📦 package.json 변경 감지 - npm install 실행${NC}"
npm install
if [ $? -ne 0 ]; then
echo -e "${RED}❌ npm install 실패${NC}"
exit 1
fi
echo -e "${GREEN}✅ npm install 완료${NC}"
else
echo -e "${GREEN}✅ package.json 변경 없음 - 건너뜀${NC}"
fi
echo ""
# 3. 데이터베이스 마이그레이션
echo -e "${YELLOW}3⃣ 데이터베이스 마이그레이션 시작...${NC}"
echo -e "${YELLOW}⚠️ 주의: 마이그레이션 전 데이터베이스 백업을 권장합니다.${NC}"
echo ""
read -p "마이그레이션을 실행하시겠습니까? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
npm run db:migrate
if [ $? -ne 0 ]; then
echo -e "${RED}❌ 마이그레이션 실패${NC}"
echo -e "${YELLOW}💡 롤백이 필요하면 다음 명령어를 실행하세요:${NC}"
echo -e "${YELLOW} npm run db:rollback${NC}"
exit 1
fi
echo -e "${GREEN}✅ 마이그레이션 완료${NC}"
else
echo -e "${YELLOW}⏭️ 마이그레이션 건너뜀${NC}"
fi
echo ""
# 4. PM2 재시작
echo -e "${YELLOW}4⃣ PM2 서버 재시작...${NC}"
if command -v pm2 &> /dev/null; then
pm2 reload ecosystem.config.js --env production
if [ $? -ne 0 ]; then
echo -e "${RED}❌ PM2 reload 실패${NC}"
exit 1
fi
echo -e "${GREEN}✅ PM2 reload 완료${NC}"
echo ""
# PM2 상태 확인
echo -e "${BLUE}📊 PM2 프로세스 상태:${NC}"
pm2 list
else
echo -e "${YELLOW}⚠️ PM2가 설치되지 않았습니다. 수동으로 서버를 재시작해주세요.${NC}"
fi
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} ✅ 배포 완료!${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo -e "${BLUE}📝 배포 후 확인사항:${NC}"
echo -e " 1. API 서버 응답 확인: curl http://localhost:20005/health"
echo -e " 2. 로그 확인: pm2 logs hyungi-api"
echo -e " 3. 에러 발생 시: pm2 logs hyungi-api --err"
echo ""