Start or restart the local dev server for the iOS simulator in a tmux session
Manage the flightforms tmux session that runs the FastAPI backend with SSL so the iOS simulator can reach it at https://localhost.ro-z.me:8443.
Figure out the correct project root (PROJECT_ROOT):
src/ dir, or .git is a file not a directory), the working directory IS the project root for that worktree$PROJECT_ROOT/venv/ exists, use it$PROJECT_ROOT/../main/venv/ (worktree case sharing main's venv)Store the resolved path as VENV_PATH.
When using a shared venv (especially ../main/venv/), the package is installed in editable mode and the path may point elsewhere.
source $VENV_PATH/bin/activate
pip show flightforms | grep Location
$PROJECT_ROOT, re-install:
pip install -e "$PROJECT_ROOT"
$PROJECT_ROOT/.env exists, good — nothing to do.env:
ENVIRONMENT=development
JWT_SECRET=dev-secret-not-for-production
Tell the user it was created. In dev mode, flyfun-common uses SQLite and creates a dev user automatically — no MySQL or OAuth credentials needed.Run: tmux has-session -t flightforms 2>/dev/null
If a session exists:
Check what directory it's running in: tmux display-message -t flightforms -p '#{pane_current_path}'
Compare that path to $PROJECT_ROOT
If the directory matches, check if non-Python files have changed since the server started. uvicorn --reload only watches .py files, so JSON mappings and XLSX templates require a manual restart.
Get the server start time (the tmux session creation time):
tmux display-message -t flightforms -p '#{session_created}'
Then check if any mapping or template files are newer:
find "$PROJECT_ROOT/src/flightforms/mappings" "$PROJECT_ROOT/src/flightforms/templates" \
-type f \( -name "*.json" -o -name "*.xlsx" \) \
-newer <(ls -la --time-style=+%s) 2>/dev/null
Or more reliably, use stat to compare modification times of those files against the session creation timestamp.
If no non-Python files changed, tell the user:
Dev server already running at https://localhost.ro-z.me:8443 — attach with
tmux attach -t flightformsThen stop (no restart needed).
If JSON/XLSX files changed since the server started, restart the server:
tmux send-keys -t flightforms C-c
sleep 1
Then continue to Step 6 to start fresh in the existing session (skip creating a new tmux session — just send the uvicorn command to the existing pane). Tell the user: "Restarted dev server — JSON mappings/templates changed since last start."
If the directory does NOT match (e.g., switched worktrees), kill the session:
Check that the SSL certs exist:
ls /usr/local/etc/letsencrypt/live/ro-z.me/fullchain.pem
ls /usr/local/etc/letsencrypt/live/ro-z.me/privkey.pem
If either is missing, tell the user and stop.
Store paths:
SSL_CERT=/usr/local/etc/letsencrypt/live/ro-z.me/fullchain.pemSSL_KEY=/usr/local/etc/letsencrypt/live/ro-z.me/privkey.pemCreate a new tmux session running the backend:
# Create detached session
tmux new-session -d -s flightforms -c "$PROJECT_ROOT"
# Run uvicorn with SSL on port 8443 (what the iOS simulator expects)
tmux send-keys -t flightforms "ENVIRONMENT=development $VENV_PATH/bin/python -m uvicorn flightforms.api.app:create_app --factory --reload --host 0.0.0.0 --port 8443 --ssl-certfile $SSL_CERT --ssl-keyfile $SSL_KEY" Enter
Tell the user:
tmux attach -t flightformsuvicorn --reload watches for Python file changes automaticallytmux kill-session -t flightforms
Then continue to Step 5 to create a fresh one.