scense/start.sh

24 lines
767 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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 </dev/null &
sleep 2
pid=$(pgrep -f "python.*app/scense.py" | head -1 || true)
if [ -z "${pid}" ]; then
echo "ERROR: scense failed to start; logs/scense.log tail:" >&2
tail -30 logs/scense.log >&2 || true
exit 1
fi
echo "scense started: pid=${pid} port=${APP_PORT}"