| 1–17 |
JSDoc 주석 |
역할 설명(포트 할당, Python 실행, health 폴링, IPC, 종료 처리), v2.2 EPIPE 수정 변경 이력 |
| 19–23 |
import |
electron(app, BrowserWindow, ipcMain, Menu, dialog, nativeTheme), child_process.spawn, path, net, http |
| 26–30 |
상태 변수 |
mainWindow, pythonProcess, backendPort, isQuitting — 런타임 상태 |
| 32–35 |
경로 설정 |
isDev(app.isPackaged), BACKEND_DIR — 개발/프로덕션 백엔드 디렉토리 분기 |
| 38–44 |
EPIPE 방어 |
process.stdout/stderr.on("error") — EPIPE 크래시 방지 전역 핸들러 |
| 46–57 |
safeLog() / safeError() |
EPIPE 안전 로깅 래퍼 함수 |
| 68–78 |
findFreePort() |
net.createServer().listen(0) — OS 임시 포트 동적 할당 |
| 87–145 |
startPythonBackend(port) |
spawn("python", ["main.py", "--port", port]), stdio pipe, PYTHONUNBUFFERED, stdout/stderr EPIPE 방어 핸들러 |
| 152–190 |
waitForBackend(port) |
http.get(/health) 폴링 최대 60회(500ms 간격, 30초), 200 응답 대기 |
| 194–238 |
killPythonProcess() |
stdout/stderr 파이프 destroy → Windows taskkill /pid /f /t 또는 Unix SIGTERM/SIGKILL 종료 |
| 242–275 |
createWindow() |
BrowserWindow(1600×1000, minWidth 1200, titleBarStyle: "hidden", titleBarOverlay, nativeTheme dark), preload, Vite DEV URL 또는 dist/index.html, maximize, 메뉴 제거 |
| 286–313 |
IPC 핸들러 |
get-backend-port→포트 반환, select-folder→폴더 다이얼로그, get-backend-status→포트+running 상태 |
| 319–340 |
app.whenReady() |
findFreePort → startPythonBackend → waitForBackend → createWindow, macOS activate 처리 |
| 343–358 |
종료 처리 |
window-all-closed→앱 종료(macOS 제외), before-quit/will-quit→killPythonProcess 호출 |