feat(monitor): wire isolated target recovery
Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
2d4e4878ae
commit
5f3a6953ee
16 files changed
+1919
-73
No files matched your search
@@ -27,9 +27,15 @@ unset ss_password
|
||||
|
||||
server_pid=
|
||||
local_pid=
|
||||
monitor_pid=
|
||||
zapret_started=0
|
||||
cleanup() {
|
||||
trap - EXIT INT TERM
|
||||
# Let the monitor cancel/join scans and restore committed bytes BEFORE stop.
|
||||
if [ -n "$monitor_pid" ]; then
|
||||
kill -TERM "$monitor_pid" 2>/dev/null || true
|
||||
wait "$monitor_pid" 2>/dev/null || true
|
||||
fi
|
||||
# Dedicated PID/network namespace: no host/other-target stop.
|
||||
if [ "$zapret_started" -eq 1 ]; then
|
||||
/opt/zapret2/init.d/sysv/zapret2 stop || true
|
||||
@@ -59,17 +65,26 @@ until awk '$2 == "00000000:0438" && $4 == "0A" { found=1 } END { exit !found }'
|
||||
sleep 1
|
||||
done
|
||||
if [ ! -e "$ZAPRET_CONFIG" ]; then
|
||||
zapret-autotune managed init
|
||||
/usr/local/bin/zapret-autotune managed init
|
||||
else
|
||||
# Never reinitialize/adopt persisted state; drift/pending state fails closed.
|
||||
zapret-autotune managed status
|
||||
/usr/local/bin/zapret-autotune managed status
|
||||
fi
|
||||
zapret_started=1
|
||||
/opt/zapret2/init.d/sysv/zapret2 start
|
||||
|
||||
# Process supervision only; no managed monitor/recovery command exists yet.
|
||||
while kill -0 "$server_pid" && kill -0 "$local_pid"; do
|
||||
/usr/local/bin/zapret-autotune managed monitor &
|
||||
monitor_pid=$!
|
||||
while kill -0 "$server_pid" && kill -0 "$local_pid" && kill -0 "$monitor_pid"; do
|
||||
sleep 1
|
||||
done
|
||||
echo 'error: target Shadowsocks process exited' >&2
|
||||
if ! kill -0 "$monitor_pid" 2>/dev/null; then
|
||||
code=0
|
||||
wait "$monitor_pid" || code=$?
|
||||
monitor_pid=
|
||||
echo 'error: target managed monitor exited' >&2
|
||||
[ "$code" -ne 0 ] || code=1
|
||||
exit "$code"
|
||||
fi
|
||||
echo 'error: target child process exited' >&2
|
||||
exit 1
|
||||
Reference in new issue
Block a user