修复 start.sh 中多余的日志机制

This commit is contained in:
Tian jianyong 2025-12-26 17:12:55 +08:00
parent 70c4641472
commit 82683d380c

View File

@ -1,30 +1,15 @@
#!/bin/bash
# --- 日志相关 ---
LOG_DIR="/home/unitree/robot_face_rec/logs/face_rec"
# 创建日志目录
LOG_DIR="/home/unitree/robot_face_rec/logs"
mkdir -p "$LOG_DIR"
LOG_FILE="$LOG_DIR/face_rec_$(date +%Y%m%d_%H%M%S).log"
{
echo "===== $(date) Starting face_rec script ====="
echo "User: $(whoami)"
echo "PWD before cd: $(pwd)"
echo "Python: $(which python) / Version: $(python --version 2>&1)"
} >> "$LOG_FILE"
# 切换到项目目录
cd /home/unitree/robot_face_rec || {
echo "Failed to cd to project dir" >> "$LOG_FILE"
echo "Failed to cd to project dir"
exit 1
}
{
echo "PWD after cd: $(pwd)"
echo "Env before display detection: DISPLAY=$DISPLAY, XAUTHORITY=$XAUTHORITY"
} >> "$LOG_FILE"
# --- DISPLAY 和 XAUTHORITY 设置逻辑 ---
# 设置DISPLAY环境变量
# 使用Linux系统最常见的默认值:0
export DISPLAY=":0"
@ -61,12 +46,5 @@ fi
export XAUTHORITY="$xauth_path"
echo "Using XAUTHORITY: $XAUTHORITY"
export XAUTHORITY="$xauth_path"
{
echo "Chosen DISPLAY = $DISPLAY"
echo "Using XAUTHORITY = $XAUTHORITY"
} >> "$LOG_FILE"
# 最终执行 Python 程序(不后台化,用 exec 替换进程)
exec python face_rec.py >> "$LOG_FILE" 2>&1
# 执行 Python 程序Python 代码自己管理日志)
exec python face_rec.py