feat: 서버 시작/중지 스크립트 추가

- scripts/start_server.ps1: 기존 프로세스 종료 후 시작
- scripts/stop_server.ps1: 서버 중지
- scripts/*.bat: 더블클릭 실행용
This commit is contained in:
thug0bin 2026-02-27 14:55:46 +09:00
parent 6e23dc8b20
commit c4ab865c93
4 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,4 @@
@echo off
chcp 65001 >nul
powershell -ExecutionPolicy Bypass -File "%~dp0start_server.ps1"
pause

View File

@ -0,0 +1,35 @@
# 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
}

View File

@ -0,0 +1,4 @@
@echo off
chcp 65001 >nul
powershell -ExecutionPolicy Bypass -File "%~dp0stop_server.ps1"
pause

View File

@ -0,0 +1,15 @@
# stop_server.ps1 - Flask 서버 중지 스크립트
$PORT = 7001
Write-Host "=== 청춘약국 마일리지 서버 중지 ===" -ForegroundColor Cyan
$netstat = netstat -ano | Select-String ":$PORT.*LISTENING"
if ($netstat) {
$pid = ($netstat -split '\s+')[-1]
Write-Host "서버 프로세스 종료 중 (PID: $pid)..." -ForegroundColor Yellow
taskkill /F /PID $pid 2>$null
Write-Host "=== 서버 중지 완료 ===" -ForegroundColor Green
} else {
Write-Host "실행 중인 서버가 없습니다." -ForegroundColor Yellow
}