-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_preview.sh
More file actions
executable file
·48 lines (42 loc) · 1.47 KB
/
run_preview.sh
File metadata and controls
executable file
·48 lines (42 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env zsh
emulate -L zsh
set -euo pipefail
if [[ ! -d ".venv" ]]; then
print -u2 "Missing .venv in $(pwd). Run: uv sync"
exit 1
fi
if [[ ! -d "../.razorcore" ]]; then
print -u2 "Missing ../.razorcore. This app requires a sibling .razorcore worktree."
exit 1
fi
if ! uv run python - <<'PY' >/dev/null 2>&1
import importlib
importlib.import_module("PySide6")
importlib.import_module("razorcore")
PY
then
print -u2 "Dependencies missing in .venv; running uv sync..."
uv sync
fi
# Start a minimal HTTP status server so preview_start can detect readiness.
# preview_start checks the configured port; without a listener it sends SIGTERM.
STATUS_PORT="${PORT:-3001}"
uv run python -c "
import http.server, socketserver, sys, threading
class H(http.server.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write(b'L!bra running')
def log_message(self, *_): pass
socketserver.TCPServer.allow_reuse_address = True
httpd = socketserver.TCPServer(('127.0.0.1', int(sys.argv[1])), H)
threading.Thread(target=httpd.serve_forever, daemon=True).start()
import time; time.sleep(86400)
" "$STATUS_PORT" &
STATUS_PID=$!
# Clean up status server when this script exits for any reason.
cleanup() { kill $STATUS_PID 2>/dev/null || true; }
trap cleanup EXIT TERM INT
# Launch the GUI app (no exec — keep shell alive so trap fires on exit).
env PYTHONPATH="src${PYTHONPATH:+:$PYTHONPATH}" uv run -- python -m Libra.main "$@"