hgzero/ai-python/restart.sh
Minseo-Jo 92c18f71c0 AI 서비스 재시작 스크립트 개선 및 STT 서비스 수정
- AI 서비스 reload 설정 비활성화 (포트 충돌 방지)
- start.sh 삭제 및 restart.sh로 대체
- STT 서비스 로깅 및 WebSocket 핸들러 개선
- 회의 안건 섹션 마이그레이션 SQL 추가

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 10:51:19 +09:00

116 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
# AI Python 서비스 재시작 스크립트
# 8086 포트로 깔끔하게 재시작
echo "=================================="
echo "AI Python 서비스 재시작"
echo "=================================="
# 1. 기존 프로세스 종료
echo "1⃣ 기존 프로세스 정리 중..."
pkill -9 -f "python.*main.py" 2>/dev/null
pkill -9 -f "uvicorn.*8086" 2>/dev/null
pkill -9 -f "uvicorn.*8087" 2>/dev/null
# 잠시 대기 (포트 해제 대기)
sleep 2
# 2. 포트 확인
echo "2⃣ 포트 상태 확인..."
if lsof -i:8086 > /dev/null 2>&1; then
echo " ⚠️ 8086 포트가 아직 사용 중입니다."
echo " 강제 종료 시도..."
PID=$(lsof -ti:8086)
if [ ! -z "$PID" ]; then
kill -9 $PID
sleep 2
fi
fi
if lsof -i:8086 > /dev/null 2>&1; then
echo " ❌ 8086 포트를 해제할 수 없습니다."
echo " 시스템 재부팅 후 다시 시도하거나,"
echo " 다른 포트를 사용하세요."
exit 1
else
echo " ✅ 8086 포트 사용 가능"
fi
# 3. 가상환경 활성화
echo "3⃣ 가상환경 활성화..."
if [ ! -d "venv" ]; then
echo " ❌ 가상환경이 없습니다. venv 디렉토리를 생성하세요."
exit 1
fi
source venv/bin/activate
echo " ✅ 가상환경 활성화 완료"
# 4. 로그 디렉토리 확인
mkdir -p ../logs
# 5. 서비스 시작
echo "4⃣ AI Python 서비스 시작 (포트: 8086)..."
nohup python3 main.py > ../logs/ai-python.log 2>&1 &
PID=$!
echo " PID: $PID"
echo " 로그: ../logs/ai-python.log"
# 6. 시작 대기
echo "5⃣ 서비스 시작 대기 (7초)..."
sleep 7
# 7. 상태 확인
echo "6⃣ 서비스 상태 확인..."
# 프로세스 확인
if ps -p $PID > /dev/null; then
echo " ✅ 프로세스 실행 중 (PID: $PID)"
else
echo " ❌ 프로세스 종료됨"
echo " 로그 확인:"
tail -20 ../logs/ai-python.log
exit 1
fi
# 포트 확인
if lsof -i:8086 > /dev/null 2>&1; then
echo " ✅ 8086 포트 리스닝 중"
else
echo " ⚠️ 8086 포트 아직 준비 중..."
fi
# Health 체크
echo "7⃣ Health Check..."
sleep 2
HEALTH=$(curl -s http://localhost:8086/health 2>/dev/null)
if [ $? -eq 0 ]; then
echo " ✅ Health Check 성공"
echo " $HEALTH"
else
echo " ⚠️ Health Check 실패 (서버가 아직 시작 중일 수 있습니다)"
echo ""
echo " 최근 로그:"
tail -10 ../logs/ai-python.log
fi
echo ""
echo "=================================="
echo "✅ AI Python 서비스 시작 완료"
echo "=================================="
echo "📊 서비스 정보:"
echo " - PID: $PID"
echo " - 포트: 8086"
echo " - 로그: tail -f ../logs/ai-python.log"
echo ""
echo "📡 엔드포인트:"
echo " - Health: http://localhost:8086/health"
echo " - Root: http://localhost:8086/"
echo " - Swagger: http://localhost:8086/swagger-ui.html"
echo ""
echo "🛑 서비스 중지: pkill -f 'python.*main.py'"
echo "=================================="