| 1234567891011121314151617181920212223242526272829303132333435 |
- #!/bin/bash
- # Gracefully stop 24-PTC stress test and drive all PTC to 0%
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
- PID_FILE="${SCRIPT_DIR}/stress.pid"
- if [ -f "${PID_FILE}" ]; then
- PID=$(cat "${PID_FILE}")
- else
- PID=$(pgrep -f "stress_test_35ptc_24h.py")
- fi
- if [ -z "${PID}" ] || ! ps -p "${PID}" > /dev/null 2>&1; then
- echo "[INFO] No running stress test found."
- rm -f "${PID_FILE}"
- exit 0
- fi
- echo "[INFO] Sending SIGTERM to PID ${PID} to trigger safe shutdown (PTC 0%)..."
- kill -TERM "${PID}"
- # Wait up to 10 seconds for graceful shutdown
- for i in $(seq 1 10); do
- if ! ps -p "${PID}" > /dev/null 2>&1; then
- echo "[OK] Stress test process ${PID} terminated gracefully."
- rm -f "${PID_FILE}"
- exit 0
- fi
- sleep 1
- done
- echo "[WARNING] Process did not terminate within 10s, forcing kill..."
- kill -9 "${PID}" 2>/dev/null
- rm -f "${PID_FILE}"
- echo "[DONE]"
|