- scripts/start_server.ps1: 기존 프로세스 종료 후 시작 - scripts/stop_server.ps1: 서버 중지 - scripts/*.bat: 더블클릭 실행용
36 lines
1.3 KiB
PowerShell
36 lines
1.3 KiB
PowerShell
# start_server.ps1 - Flask 서버 시작 스크립트
|
|
# 기존 프로세스 종료 후 새로 시작
|
|
|
|
$PORT = 7001
|
|
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$BACKEND_DIR = Split-Path -Parent $SCRIPT_DIR
|
|
|
|
Write-Host "=== 청춘약국 마일리지 서버 시작 ===" -ForegroundColor Cyan
|
|
|
|
# 1. 기존 포트 사용 프로세스 종료
|
|
Write-Host "1. 포트 $PORT 확인 중..." -ForegroundColor Yellow
|
|
$netstat = netstat -ano | Select-String ":$PORT.*LISTENING"
|
|
if ($netstat) {
|
|
$pid = ($netstat -split '\s+')[-1]
|
|
Write-Host " 기존 프로세스 발견 (PID: $pid). 종료합니다..." -ForegroundColor Red
|
|
taskkill /F /PID $pid 2>$null
|
|
Start-Sleep -Seconds 2
|
|
}
|
|
|
|
# 2. 서버 시작
|
|
Write-Host "2. 서버 시작 중..." -ForegroundColor Yellow
|
|
Set-Location $BACKEND_DIR
|
|
Start-Process python -ArgumentList "app.py" -WindowStyle Hidden
|
|
|
|
# 3. 시작 확인
|
|
Start-Sleep -Seconds 3
|
|
$check = netstat -ano | Select-String ":$PORT.*LISTENING"
|
|
if ($check) {
|
|
Write-Host "=== 서버 시작 완료! ===" -ForegroundColor Green
|
|
Write-Host "URL: http://localhost:$PORT" -ForegroundColor Cyan
|
|
Write-Host "외부: http://192.168.0.14:$PORT" -ForegroundColor Cyan
|
|
} else {
|
|
Write-Host "=== 서버 시작 실패 ===" -ForegroundColor Red
|
|
Write-Host "로그를 확인하세요." -ForegroundColor Red
|
|
}
|