Files
juc500/start.sh
T
joyharam a423db0556 Restart stale GUI and avoid port 8765 clash with fileShare
Old juc500_app processes kept serving pre-fix code; start.sh now
kills them and GUI defaults to port 8766.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 12:20:15 +09:00

50 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# JUC500 GUI 실행 (인자 없으면 GUI, 있으면 CLI로 전달)
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
if [[ -x "$ROOT/.venv/bin/python" ]]; then
PY="$ROOT/.venv/bin/python"
elif command -v python3 >/dev/null 2>&1; then
PY="$(command -v python3)"
else
echo "Python3 가 없습니다. 먼저 설치하세요:" >&2
echo " ./scripts/setup_macos.sh" >&2
exit 1
fi
if [[ ! -x "$ROOT/.venv/bin/python" ]]; then
echo "경고: .venv 없음 — 시스템 Python 사용. 문제가 있으면 ./scripts/setup_macos.sh" >&2
fi
export PYTHONPATH="$ROOT${PYTHONPATH:+:$PYTHONPATH}"
# 의존성 빠른 확인
if ! "$PY" -c "import usb" 2>/dev/null; then
echo "pyusb 가 없습니다. 먼저 설치하세요:" >&2
echo " ./scripts/setup_macos.sh" >&2
exit 1
fi
# 이전 GUI 인스턴스 종료 (옛 코드가 포트 8765를 붙잡고 있으면 같은 에러가 반복됨)
if command -v pgrep >/dev/null 2>&1; then
OLD_PIDS="$(pgrep -f "$ROOT/juc500_app.py" || true)"
if [[ -n "${OLD_PIDS}" ]]; then
echo "이전 JUC500 프로세스 종료: ${OLD_PIDS}"
# shellcheck disable=SC2086
kill ${OLD_PIDS} 2>/dev/null || true
sleep 0.4
# shellcheck disable=SC2086
kill -9 ${OLD_PIDS} 2>/dev/null || true
fi
fi
# 캐시된 .pyc 가 헷갈리지 않도록 (경량)
rm -rf "$ROOT/juc500_xfer/__pycache__" 2>/dev/null || true
REV="$("$PY" -c "from juc500_xfer import __version__; from juc500_xfer.usb_link import Juc500Link; print(__version__, 'backend_io=' + str(hasattr(Juc500Link, '_backend_bulk_write')))")"
echo "JUC500 start — ${REV}"
exec "$PY" "$ROOT/juc500_app.py" "$@"