office_gzweb/run_all_stop.sh

32 lines
1.0 KiB
Bash
Executable File
Raw Permalink 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
set -euo pipefail
# run_all_stop.sh — 干净停止所有仿真、导航、视觉进程
echo "[run_all_stop] Stopping all simulation processes..."
# 1. 发送循环停止信号(让 run_all.sh 优雅退出)
touch /workspace/.run_all_stop
# 2. 发送 SIGTERM 给 run_all.sh触发其 cleanup trap
PIDS=$(pgrep -f "run_all\.sh" | grep -v $$ || true)
if [[ -n "$PIDS" ]]; then
echo "[run_all_stop] Sending SIGTERM to run_all.sh: $PIDS"
kill $PIDS 2>/dev/null || true
fi
# 3. 等待优雅退出
sleep 3
# 4. 强制清理残留的 ROS2 / Gazebo / 视觉进程
echo "[run_all_stop] Force killing remaining processes..."
pkill -9 -f "gz sim\|gz launch\|ros2 launch\|ros2 run" 2>/dev/null || true
pkill -9 -f "explore_lite\|nav2_bringup\|turtlebot3_gazebo" 2>/dev/null || true
pkill -9 -f "vision_yolo\|vision_daemon" 2>/dev/null || true
pkill -9 -f "selkies-gstreamer\|code-server" 2>/dev/null || true
# 5. 清理状态文件
rm -f /workspace/.run_all_stop
rm -f /workspace/.vision_daemon_stop
echo "[run_all_stop] All processes stopped."