xiaowei-system/scripts/fix-gateway-takeover.sh

25 lines
895 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
# 修复 hermes-gateway 接管:停崩溃循环 → 释放 8644 → 正统服务接管
# 由 systemd-run 从 gateway 外部执行独立进程树SIGTERM 不传播)
LOG=/tmp/gateway-fix.log
echo "=== $(date '+%F %T') 开始执行 ===" > "$LOG"
sleep 4 # 给当前会话留出发送回复的时间
echo "--- 1. 停崩溃循环 ---" >> "$LOG"
systemctl --user stop hermes-gateway >> "$LOG" 2>&1
systemctl --user reset-failed hermes-gateway >> "$LOG" 2>&1
echo "stop/reset-failed exit=$?" >> "$LOG"
echo "--- 2. 释放 8644 (kill 2198677) ---" >> "$LOG"
kill 2198677 >> "$LOG" 2>&1
echo "kill exit=$?" >> "$LOG"
sleep 1
echo "--- 3. 正统服务接管 ---" >> "$LOG"
systemctl --user start hermes-gateway >> "$LOG" 2>&1
echo "start exit=$?" >> "$LOG"
sleep 2
systemctl --user status hermes-gateway --no-pager >> "$LOG" 2>&1
echo "=== 完成 $(date '+%F %T') ===" >> "$LOG"