Initial commit: Organized PTC project structure with .gitignore and README
This commit is contained in:
14
windows/README.txt
Normal file
14
windows/README.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
사용 파일
|
||||
- start_ptc_share.bat : 관리자 권한으로 실행되며, WSL 서버 시작 + portproxy + 방화벽까지 자동 설정
|
||||
- stop_ptc_share.bat : 공유 중지
|
||||
- check_ptc_share.bat : 현재 공유 상태 확인
|
||||
|
||||
사용 순서
|
||||
1. start_ptc_share.bat 실행
|
||||
2. 브라우저에서 http://172.16.40.36:8000/PTC/ 확인
|
||||
3. 안 되면 check_ptc_share.bat 실행
|
||||
|
||||
주의
|
||||
- PC가 켜져 있어야 합니다.
|
||||
- WSL이 재시작되어 IP가 바뀌면 start_ptc_share.bat 를 다시 실행하세요.
|
||||
- 관리자 권한이 필요합니다.
|
||||
20
windows/check_ptc_share.bat
Normal file
20
windows/check_ptc_share.bat
Normal file
@@ -0,0 +1,20 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions
|
||||
|
||||
echo [Windows portproxy]
|
||||
netsh interface portproxy show v4tov4
|
||||
echo.
|
||||
echo [WSL web]
|
||||
wsl.exe bash -lc "curl -I -s http://127.0.0.1:8000/PTC/ | head -n 1"
|
||||
echo.
|
||||
echo [WSL api]
|
||||
wsl.exe bash -lc "curl -s http://127.0.0.1:4000/api/health"
|
||||
echo.
|
||||
echo [Office LAN web]
|
||||
powershell -NoProfile -Command "try { (Invoke-WebRequest -Uri 'http://172.16.40.36:8000/PTC/' -UseBasicParsing -TimeoutSec 5).StatusCode } catch { $_.Exception.Message }"
|
||||
echo.
|
||||
echo [Office LAN api]
|
||||
powershell -NoProfile -Command "try { (Invoke-WebRequest -Uri 'http://172.16.40.36:4000/api/health' -UseBasicParsing -TimeoutSec 5).Content } catch { $_.Exception.Message }"
|
||||
echo.
|
||||
pause
|
||||
|
||||
70
windows/start_ptc_share.bat
Normal file
70
windows/start_ptc_share.bat
Normal file
@@ -0,0 +1,70 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions EnableDelayedExpansion
|
||||
|
||||
set "PROJECT_DIR=/home/hyein/project"
|
||||
set "WEB_PORT=8000"
|
||||
set "API_PORT=4000"
|
||||
|
||||
net session >nul 2>&1
|
||||
if not "%errorlevel%"=="0" (
|
||||
echo 관리자 권한으로 다시 실행합니다...
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
|
||||
exit /b
|
||||
)
|
||||
|
||||
echo WSL IP 확인 중...
|
||||
for /f "usebackq delims=" %%i in (`wsl.exe bash -lc "hostname -I | cut -d' ' -f1"`) do (
|
||||
set "WSL_IP=%%i"
|
||||
)
|
||||
|
||||
if "%WSL_IP%"=="" (
|
||||
echo WSL IP를 확인하지 못했습니다.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
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
|
||||
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 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
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
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
|
||||
|
||||
24
windows/stop_ptc_share.bat
Normal file
24
windows/stop_ptc_share.bat
Normal file
@@ -0,0 +1,24 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions
|
||||
|
||||
net session >nul 2>&1
|
||||
if not "%errorlevel%"=="0" (
|
||||
echo 관리자 권한으로 다시 실행합니다...
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
|
||||
exit /b
|
||||
)
|
||||
|
||||
echo 포트포워딩 제거 중...
|
||||
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=8000 >nul 2>&1
|
||||
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=4000 >nul 2>&1
|
||||
|
||||
echo 방화벽 규칙 제거 중...
|
||||
netsh advfirewall firewall delete rule name="PTC 8000" >nul 2>&1
|
||||
netsh advfirewall firewall delete rule name="PTC 4000" >nul 2>&1
|
||||
|
||||
echo WSL 서버 종료 중...
|
||||
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"
|
||||
|
||||
echo 종료 완료
|
||||
pause
|
||||
|
||||
Reference in New Issue
Block a user