Files
TalkEdit/open
2026-04-09 01:36:28 -06:00

69 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
# Open TalkEdit app (Tauri dev mode)
cd "$(dirname "$0")"
PROJECT_DIR="$PWD"
BACKEND_PORT=8000
BACKEND_URL="http://127.0.0.1:${BACKEND_PORT}/health"
# Check if backend is already running
if curl -sf "$BACKEND_URL" > /dev/null 2>&1; then
echo "Backend already running on port ${BACKEND_PORT}."
else
echo "Backend not running — starting it in a new terminal..."
VENV_PYTHON=""
PYTHON_CANDIDATES=(
"${PROJECT_DIR}/.venv312/bin/python3.12"
"${PROJECT_DIR}/.venv312/bin/python"
"${PROJECT_DIR}/.venv/bin/python3"
"${PROJECT_DIR}/.venv/bin/python"
"${PROJECT_DIR}/venv/bin/python3"
"${PROJECT_DIR}/venv/bin/python"
)
for candidate in "${PYTHON_CANDIDATES[@]}"; do
if [[ -x "${candidate}" ]]; then
VENV_PYTHON="${candidate}"
break
fi
done
if [[ -z "${VENV_PYTHON}" ]]; then
echo "No project virtualenv Python found. Checked: .venv312, .venv, venv"
exit 1
fi
BACKEND_DIR="${PROJECT_DIR}/backend"
# Try common terminal emulators in order
if command -v ghostty &>/dev/null; then
ghostty -e bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" &
elif command -v kitty &>/dev/null; then
kitty --title "TalkEdit Backend" -- bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" &
elif command -v alacritty &>/dev/null; then
alacritty --title "TalkEdit Backend" -e bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" &
elif command -v konsole &>/dev/null; then
konsole --new-tab -e bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" &
elif command -v gnome-terminal &>/dev/null; then
gnome-terminal --title "TalkEdit Backend" -- bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" &
elif command -v xterm &>/dev/null; then
xterm -T "TalkEdit Backend" -e bash -c "cd '${BACKEND_DIR}' && '${VENV_PYTHON}' -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT}; exec bash" &
else
echo "No supported terminal emulator found. Starting backend in background..."
cd "${BACKEND_DIR}" && "${VENV_PYTHON}" -m uvicorn main:app --host 127.0.0.1 --port ${BACKEND_PORT} &
fi
# Wait up to 15s for backend to become ready
echo -n "Waiting for backend"
for i in $(seq 1 15); do
sleep 1
echo -n "."
if curl -sf "$BACKEND_URL" > /dev/null 2>&1; then
echo " ready!"
break
fi
if [[ $i -eq 15 ]]; then
echo " timed out. Check the backend terminal for errors."
fi
done
fi
npx tauri dev