[PR #5508] [CLOSED] Remove force-restart on client disable — sync stored config instead #5907

Closed
opened 2026-11-02 04:04:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5508
Author: @SKITTLE6969
Created: 6/23/2026
Status: ❌ Closed

Base: main ← Head: main


📝 Commits (4)

  • 7a6335e v3.4.0
  • 996d1f5 Remove force-restart on client disable — sync stored config instead
  • 2633f46 Merge branch 'main' into main
  • 35c31e2 Update version

📊 Changes

2 files changed (+8 additions, -6 deletions)

View changed files

📝 internal/web/job/node_traffic_sync_job.go (+4 -3)
📝 internal/web/job/xray_traffic_job.go (+4 -3)

📄 Description

refactor(job): replace Xray force-restart with config sync to preserve active connections

After `disableInvalidClients` removes over-quota or expired users via
the gRPC RemoveUser API, the runtime state already matches the desired
state. Calling `RestartXray(true)` forced an unnecessary restart that
dropped active connections.

This replaces the force-restart in both the traffic timer and multi-node
sync paths with a lightweight memory config sync:

```go
if proc := service.XrayProcess(); proc != nil {
    if newCfg, cfgErr := j.xrayService.GetXrayConfig(); cfgErr == nil {
        proc.SetConfig(newCfg)
    }
}

By syncing the stored config in-memory without calling the Xray API,
the running instance remains untouched, and future hot diffs
(tryHotApply/ComputeHotDiff) can accurately track state changes.


Summary

Replaces an aggressive Xray force-restart with a lightweight in-memory configuration sync after invalid clients are removed at runtime.

Why

Calling RestartXray(true) after runtime user removal dropped all active connections unnecessarily, as the running instance was already in the desired state. This preserves active connections and ensures future hot-diff checks are accurate.

Type of change

  • Refactoring (no behavior change)

Areas affected

  • Xray config generation
  • Statistics / traffic counters
  • Multi-node (sub-nodes)

Breaking changes

None

Files changed

  • internal/web/job/xray_traffic_job.go
  • internal/web/job/node_traffic_sync_job.go


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5508 **Author:** [@SKITTLE6969](https://github.com/SKITTLE6969) **Created:** 6/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (4) - [`7a6335e`](https://github.com/MHSanaei/3x-ui/commit/7a6335eba3465474dade18c1c99ef288b4a410a7) v3.4.0 - [`996d1f5`](https://github.com/MHSanaei/3x-ui/commit/996d1f5f7a4987d314ea0c28263cb548cd1b69b2) Remove force-restart on client disable — sync stored config instead - [`2633f46`](https://github.com/MHSanaei/3x-ui/commit/2633f46eb177cf5e6a27fd09b8ac990a3e8b2e19) Merge branch 'main' into main - [`35c31e2`](https://github.com/MHSanaei/3x-ui/commit/35c31e2a41cd60ce2b30692cdfa316a95422a4d0) Update version ### 📊 Changes **2 files changed** (+8 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/job/node_traffic_sync_job.go` (+4 -3) 📝 `internal/web/job/xray_traffic_job.go` (+4 -3) </details> ### 📄 Description ```text refactor(job): replace Xray force-restart with config sync to preserve active connections After `disableInvalidClients` removes over-quota or expired users via the gRPC RemoveUser API, the runtime state already matches the desired state. Calling `RestartXray(true)` forced an unnecessary restart that dropped active connections. This replaces the force-restart in both the traffic timer and multi-node sync paths with a lightweight memory config sync: ```go if proc := service.XrayProcess(); proc != nil { if newCfg, cfgErr := j.xrayService.GetXrayConfig(); cfgErr == nil { proc.SetConfig(newCfg) } } ``` By syncing the stored config in-memory without calling the Xray API, the running instance remains untouched, and future hot diffs (`tryHotApply`/`ComputeHotDiff`) can accurately track state changes. --- ## Summary Replaces an aggressive Xray force-restart with a lightweight in-memory configuration sync after invalid clients are removed at runtime. ## Why Calling `RestartXray(true)` after runtime user removal dropped all active connections unnecessarily, as the running instance was already in the desired state. This preserves active connections and ensures future hot-diff checks are accurate. ## Type of change * [x] Refactoring (no behavior change) ## Areas affected * [x] Xray config generation * [x] Statistics / traffic counters * [x] Multi-node (sub-nodes) ## Breaking changes None ## Files changed * internal/web/job/xray_traffic_job.go * internal/web/job/node_traffic_sync_job.go ``` ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:56 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5907
No description provided.