feat: 엑셀 원본 파일 선택 기능 및 프론트엔드/백엔드 최적화
- PTC(2023-2026.02).xlsx 최신화 - PTC/index.html: 에러 핸들링, 동적 API 베이스, 예산 계산 로직 개선 및 UI 최적화 - server/ptc_api_server.py: 4000 포트에서 프론트엔드 직접 서빙, 원본 엑셀 경로 설정 기능, DB 인덱스 추가 및 성능 최적화 - windows/: 원본 파일 선택을 위한 set_ptc_source.bat 추가 및 기존 스크립트 수정
This commit is contained in:
@@ -1,70 +1,77 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions EnableDelayedExpansion
|
||||
setlocal EnableExtensions
|
||||
|
||||
set "PROJECT_DIR=/home/hyein/project"
|
||||
set "WEB_PORT=8000"
|
||||
set "API_PORT=4000"
|
||||
set "LOCAL_URL=http://localhost:4000/PTC/"
|
||||
set "SHARE_URL="
|
||||
set "LAN_IP="
|
||||
set "CURRENT_SOURCE="
|
||||
|
||||
net session >nul 2>&1
|
||||
if not "%errorlevel%"=="0" (
|
||||
echo 관리자 권한으로 다시 실행합니다...
|
||||
echo 관리자 권한으로 다시 실행해 공유 설정까지 적용합니다...
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
|
||||
exit /b
|
||||
)
|
||||
|
||||
for /f "usebackq delims=" %%i in (`wsl.exe bash -lc "if [ -f /home/hyein/project/server/ptc_source_path.txt ]; then cat /home/hyein/project/server/ptc_source_path.txt; else echo /home/hyein/project/PTC(2023-2026.02).xlsx; fi"`) do (
|
||||
set "CURRENT_SOURCE=%%i"
|
||||
)
|
||||
|
||||
echo PTC 서버 시작 중...
|
||||
echo 원본 파일: %CURRENT_SOURCE%
|
||||
wsl.exe bash -lc "pkill -f '/home/hyein/project/server/ptc_api_server.py' >/dev/null 2>&1 || true; nohup python3 /home/hyein/project/server/ptc_api_server.py >/tmp/ptc_api.log 2>&1 & sleep 3"
|
||||
if errorlevel 1 (
|
||||
echo WSL에서 서버 시작 명령 실행에 실패했습니다.
|
||||
echo WSL이 실행 가능한지 확인해 주세요.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo 로컬 서버 상태 확인 중...
|
||||
wsl.exe bash -lc "curl -fsS http://127.0.0.1:4000/api/health >/tmp/ptc_api_health.json && curl -fsSI http://127.0.0.1:4000/PTC/ >/tmp/ptc_web_health.txt"
|
||||
if errorlevel 1 (
|
||||
echo 로컬 서버 확인에 실패했습니다.
|
||||
echo 아래 로그를 확인해 주세요.
|
||||
wsl.exe bash -lc "tail -n 80 /tmp/ptc_api.log"
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo 브라우저를 엽니다...
|
||||
start "" "%LOCAL_URL%"
|
||||
|
||||
echo.
|
||||
echo 로컬 실행 완료
|
||||
echo 메인 화면: %LOCAL_URL%
|
||||
echo.
|
||||
|
||||
echo 사내망 공유용 Windows IP 확인 중...
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "$ip = Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254.*' -and $_.PrefixOrigin -ne 'WellKnown' } | Select-Object -ExpandProperty IPAddress -First 1; if ($ip) { $ip }"`) do (
|
||||
set "LAN_IP=%%i"
|
||||
)
|
||||
|
||||
echo WSL IP 확인 중...
|
||||
for /f "usebackq delims=" %%i in (`wsl.exe bash -lc "hostname -I | cut -d' ' -f1"`) do (
|
||||
for /f "usebackq delims=" %%i in (`wsl.exe bash -lc "hostname -I | awk '{print $1}'"`) do (
|
||||
set "WSL_IP=%%i"
|
||||
)
|
||||
|
||||
if "%WSL_IP%"=="" (
|
||||
echo WSL IP를 확인하지 못했습니다.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if "%LAN_IP%"=="" goto :share_done
|
||||
if "%WSL_IP%"=="" goto :share_done
|
||||
|
||||
echo WSL IP: %WSL_IP%
|
||||
echo 기존 서버 정리 및 재실행 중...
|
||||
wsl.exe bash -lc "pkill -f 'python3 -m http.server 8000' >/dev/null 2>&1 || true; pkill -f '/home/hyein/project/server/ptc_api_server.py' >/dev/null 2>&1 || true; nohup python3 -m http.server 8000 --directory /home/hyein/project >/tmp/ptc_web.log 2>&1 & nohup python3 /home/hyein/project/server/ptc_api_server.py >/tmp/ptc_api.log 2>&1 & sleep 2"
|
||||
|
||||
echo 포트포워딩 갱신 중...
|
||||
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=%WEB_PORT% >nul 2>&1
|
||||
echo 사내망 공유 설정 중...
|
||||
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=%API_PORT% >nul 2>&1
|
||||
|
||||
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=%WEB_PORT% connectaddress=%WSL_IP% connectport=%WEB_PORT%
|
||||
if errorlevel 1 (
|
||||
echo 8000 포트포워딩 설정에 실패했습니다.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=%API_PORT% connectaddress=%WSL_IP% connectport=%API_PORT%
|
||||
if errorlevel 1 (
|
||||
echo 4000 포트포워딩 설정에 실패했습니다.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo 방화벽 규칙 적용 중...
|
||||
netsh advfirewall firewall delete rule name="PTC 8000" >nul 2>&1
|
||||
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=%API_PORT% connectaddress=%WSL_IP% connectport=%API_PORT% >nul 2>&1
|
||||
netsh advfirewall firewall delete rule name="PTC 4000" >nul 2>&1
|
||||
netsh advfirewall firewall add rule name="PTC 8000" dir=in action=allow protocol=TCP localport=%WEB_PORT% >nul
|
||||
netsh advfirewall firewall add rule name="PTC 4000" dir=in action=allow protocol=TCP localport=%API_PORT% >nul
|
||||
netsh advfirewall firewall add rule name="PTC 4000" dir=in action=allow protocol=TCP localport=%API_PORT% >nul 2>&1
|
||||
|
||||
echo 서버 상태 확인 중...
|
||||
wsl.exe bash -lc "curl -s http://127.0.0.1:4000/api/health >/tmp/ptc_api_health.json && curl -I -s http://127.0.0.1:8000/PTC/ >/tmp/ptc_web_health.txt"
|
||||
if errorlevel 1 (
|
||||
echo WSL 내부 서버 확인에 실패했습니다.
|
||||
echo /tmp/ptc_api.log 와 /tmp/ptc_web.log 를 확인해 주세요.
|
||||
pause
|
||||
exit /b 1
|
||||
:share_done
|
||||
if not "%LAN_IP%"=="" (
|
||||
set "SHARE_URL=http://%LAN_IP%:%API_PORT%/PTC/"
|
||||
echo 사내망 접속 주소: %SHARE_URL%
|
||||
echo %SHARE_URL%| clip
|
||||
echo 공유 주소를 클립보드에 복사했습니다.
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 공유 준비 완료
|
||||
echo 메인 화면: http://172.16.40.36:%WEB_PORT%/PTC/
|
||||
echo API 안내 : http://172.16.40.36:%API_PORT%/
|
||||
echo.
|
||||
echo 참고: WSL이 재시작되어 IP가 바뀌면 이 파일을 다시 실행하세요.
|
||||
pause
|
||||
|
||||
|
||||
Reference in New Issue
Block a user