RESTAPI_SERVER/start-server.sh

99 lines
2.9 KiB
Bash
Raw 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.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# REST API 서버 시작 스크립트 (Linux)
echo "========================================"
echo "🚀 REST API 서버 시작"
echo "========================================"
echo
# Docker 설치 및 실행 확인
if ! command -v docker &> /dev/null; then
echo "❌ Docker가 설치되지 않았습니다."
echo " 설치 가이드: https://docs.docker.com/engine/install/"
exit 1
fi
if ! docker info &> /dev/null; then
echo "❌ Docker가 실행되지 않았습니다."
echo " Docker 서비스를 시작합니다..."
if command -v systemctl &> /dev/null; then
sudo systemctl start docker
elif command -v service &> /dev/null; then
sudo service docker start
fi
sleep 3
if ! docker info &> /dev/null; then
echo "❌ Docker 서비스 시작 실패. 수동으로 시작해주세요."
exit 1
fi
fi
echo "✅ Docker가 정상적으로 실행 중입니다."
echo
# 기존 컨테이너 정리
echo "🧹 기존 컨테이너 정리 중..."
docker stop restapi-server 2>/dev/null || true
docker rm restapi-server 2>/dev/null || true
# 이미지 빌드 (캐시 무시하여 최신 코드 반영)
echo "🏗️ Docker 이미지 빌드 중... (최신 코드 반영)"
echo " 캐시를 무시하고 처음부터 빌드합니다."
if ! docker build --no-cache -t restapi-server:latest .; then
echo "❌ 이미지 빌드 실패!"
exit 1
fi
# 서버 시작
echo "🚀 서버 시작 중..."
if docker run -d \
--name restapi-server \
--restart unless-stopped \
-p 5577:5577 \
-e NODE_ENV=production \
-e DB_HOST=39.117.244.52 \
-e DB_PORT=11521 \
-e DB_DATABASE=XE \
-e DB_USERNAME=wace \
-e DB_PASSWORD=wace0909!! \
-e PORT=5577 \
restapi-server:latest; then
echo
echo "========================================"
echo "🎉 서버가 성공적으로 시작되었습니다!"
echo "========================================"
echo
echo "📱 웹 UI: http://localhost:5577"
echo "🔐 관리자: admin / admin123!"
echo
echo " Oracle DB 연결 실패 시 자동으로 Mock DB를 사용합니다."
echo
# 서버 시작 대기
echo "🕐 서버 시작 대기 중... (15초)"
sleep 15
# 상태 확인
echo "🔍 서버 상태 확인 중..."
if curl -s http://localhost:5577/api/health > /dev/null 2>&1; then
echo "✅ 서버가 정상적으로 실행 중입니다!"
echo "🌐 브라우저에서 http://localhost:5577 을 열어보세요!"
else
echo "⚠️ 서버가 아직 시작 중일 수 있습니다."
echo " 잠시 후 http://localhost:5577 을 확인해보세요."
fi
echo
echo "📊 유용한 명령어:"
echo " 로그 확인: docker logs -f restapi-server"
echo " 서버 중지: ./stop-server.sh"
echo " 컨테이너 상태: docker ps"
echo
else
echo "❌ 서버 시작 실패!"
exit 1
fi