#!/usr/bin/env bash # Local dev launcher — runs frps-manager on :5300 with gunicorn using the # project venv. Use this when iterating without systemd. set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/.." mkdir -p runtime/conf runtime/logs instance if [ ! -x runtime/bin/frps ]; then echo "[dev] runtime/bin/frps missing — running deploy.sh to fetch it" bash scripts/deploy.sh --no-systemd --dry-run || true fi if [ ! -d venv ]; then echo "[dev] venv missing — create one and install requirements" python3 -m venv venv venv/bin/pip install -r requirements.txt fi # Ensure frps service is *not* taking port 7000/7500 while we develop if systemctl is-active --quiet frps.service 2>/dev/null; then echo "[dev] stopping existing frps.service so dev frps can take port 7000" sudo systemctl stop frps.service fi # Start frps under the dev user (not as a daemon) if not already running if ! ss -tlnp 2>/dev/null | grep -q ':7000 '; then echo "[dev] starting frps from runtime/conf/frps.toml" mkdir -p runtime/conf if [ ! -s runtime/conf/frps.toml ]; then venv/bin/python -c " import os os.environ.setdefault('FRPS_CONFIG', os.path.abspath('runtime/conf/frps.toml')) from app import write_frps_config, FRPS_CONFIG write_frps_config() print('wrote', os.environ.get('FRPS_CONFIG')) " fi nohup runtime/bin/frps -c runtime/conf/frps.toml > runtime/logs/frps.log 2>&1 & echo $! > runtime/logs/frps.pid sleep 2 fi # Initialize DB (idempotent) venv/bin/python init_db.py echo "[dev] launching gunicorn on :5300" exec venv/bin/gunicorn \ --workers 2 \ --bind 0.0.0.0:5300 \ --reload \ --access-logfile runtime/logs/web-access.log \ --error-logfile runtime/logs/web-error.log \ wsgi:app