Skip to content

Commit 164c653

Browse files
committed
fix: 启动 sing-box 时用 su 迁出冻结 cgroup
1 parent bcd6576 commit 164c653

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/module/action.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ if is_sing_box_running; then
4646
fi
4747
else
4848
log "INFO" "检测到 sing-box 未运行,准备执行启动操作..."
49-
if sh "$SERVICE_SCRIPT" start; then
49+
# su 包裹:让 sing-box 迁出冻结 cgroup,避免切后台断网
50+
if su -c "sh \"$SERVICE_SCRIPT\" start"; then
5051
echo "==================================="
5152
echo " 操作结果: NetProxy 服务已启动"
5253
echo "==================================="

src/module/customize.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ sync_to_live() {
290290
restart_proxy_if_needed() {
291291
if [ "$PROXY_WAS_RUNNING" = true ]; then
292292
print_step "重新启动代理服务..."
293-
sh "$LIVE_DIR/scripts/core/service.sh" start > /dev/null 2>&1
293+
# su 包裹:经管理器刷入时让 sing-box 迁出冻结 cgroup,避免切后台断网
294+
su -c "sh \"$LIVE_DIR/scripts/core/service.sh\" start" > /dev/null 2>&1
294295
print_ok "服务已启动"
295296
fi
296297

src/module/scripts/core/switch.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ is_service_running() {
4444
restart_service_if_allowed() {
4545
if [ "$SWITCH_ALLOW_RESTART" = "1" ]; then
4646
log "DEBUG" "回退方式:重启核心服务以应用配置"
47-
LOG_STDERR=0 LOG_LEVEL=WARN sh "$SERVICE_SCRIPT" restart core || die "重启 sing-box 服务失败"
47+
# su 包裹:让重启拉起的 sing-box 迁出冻结 cgroup (LOG_* 写入命令串内)
48+
su -c "LOG_STDERR=0 LOG_LEVEL=WARN sh \"$SERVICE_SCRIPT\" restart core" || die "重启 sing-box 服务失败"
4849
else
4950
log "WARN" "当前阶段不允许通过重启应用配置"
5051
return 1

0 commit comments

Comments
 (0)