#!/usr/bin/env bash # scense 启动脚本(部署目录 ~/scense_app,端口 9380) set -euo pipefail DEPLOY_DIR="${DEPLOY_DIR:-$HOME/scense_app}" APP_PORT="${APP_PORT:-9380}" cd "${DEPLOY_DIR}" mkdir -p logs if pgrep -f "python.*app/scense.py" >/dev/null 2>&1; then echo "scense already running: $(pgrep -f 'python.*app/scense.py' | tr '\n' ' ')" exit 0 fi nohup "${DEPLOY_DIR}/venv/bin/python" app/scense.py -w "${DEPLOY_DIR}" -p "${APP_PORT}" \ >> logs/scense.log 2>&1 &2 tail -30 logs/scense.log >&2 || true exit 1 fi echo "scense started: pid=${pid} port=${APP_PORT}"