#!/bin/zsh # Keep the local LAN server in a detached user session. It intentionally runs # in the logged-in user's context so it can read the authenticated SMB mount at # /Volumes/study. set -eu session_name='sss50' project_dir='/Users/optimx/CODE/nas/project_sss' log_file='/Users/optimx/CODE/nas/project_sss/.local-data/server-tmux.log' server_command="cd '${project_dir}' && while true; do env ASSET_ROOT='/Volumes/study/Assets/SSS50' DATA_DIR='${project_dir}/.local-data' PORT=8787 PYTHONUNBUFFERED=1 /usr/bin/python3 app.py >> '${log_file}' 2>&1; sleep 2; done" case "${1:-start}" in start) if tmux has-session -t "${session_name}" 2>/dev/null; then echo "SSS server is already running in tmux session: ${session_name}" else tmux new-session -d -s "${session_name}" "${server_command}" echo "SSS server started: http://127.0.0.1:8787" fi ;; status) tmux has-session -t "${session_name}" curl -fsS http://127.0.0.1:8787/api/health ;; logs) tail -n "${2:-80}" "${log_file}" ;; stop) tmux kill-session -t "${session_name}" echo "SSS server stopped" ;; *) echo "Usage: $0 {start|status|logs|stop}" >&2 exit 2 ;; esac