xiaowei-system/scripts/bge_mem_check.sh

15 lines
638 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.

#!/bin/bash
# bge_embed_server 内存泄漏监控脚本
# 超过 2GB 自动重启
PID=$(pgrep -f "bge_embed_server" | head -1)
if [ -n "$PID" ]; then
RSS=$(ps -o rss= -p "$PID" 2>/dev/null || echo 0)
MB=$((RSS / 1024))
if [ "$MB" -gt 2048 ]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] bge_embed 内存 ${MB}MB > 2GB重启" >> ~/.hermes/daemon/bge-restart.log
kill "$PID"
sleep 2
cd ~/.hermes && python3 scripts/bge_embed_server.py &
echo "[$(date '+%Y-%m-%d %H:%M:%S')] bge_embed 已重启新PID=$(pgrep -f bge_embed_server | head -1)" >> ~/.hermes/daemon/bge-restart.log
fi
fi