#!/usr/bin/env fish # Run the app in web mode with recommended env vars (fish shell) # Usage: ./run_web.fish # create venv if missing if not test -d venv python3 -m venv venv end # activate venv source venv/bin/activate.fish # ensure dependencies pip install -r requirements.txt # recommended env vars (adjust if needed) set -x SNAPSHOT_INTERVAL 600 # seconds (600 = 10 minutes) set -x BRIGHTNESS_THRESHOLD 50 # 0-255 set -x AUTO_START false # true to auto-start monitor inside web server # ensure CONSOLE_MODE is unset so the Flask server will run set -e CONSOLE_MODE # logging set -x LOG_DIR logs mkdir -p $LOG_DIR set -x LOG_FILE $LOG_DIR/run_web.log set -x PID_FILE $LOG_DIR/run_web.pid echo "Starting web app in background; logs: $LOG_FILE" # Use bash to ensure POSIX redirection works reliably bash -lc "python app.py > '$LOG_FILE' 2>&1 & echo \$! > '$PID_FILE'" # wait briefly for process to start sleep 1 if test -f $PID_FILE set PID (cat $PID_FILE) echo "Started pid: $PID" else echo "Failed to start process; see $LOG_FILE for details" end # tail the log so the user can see live output (Ctrl+C to stop tail but process keeps running) echo "Tailing log (press Ctrl+C to stop tail, process will continue running in background)." tail -n 200 -f $LOG_FILE