mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6686] [MERGED] Write config.json after a hot apply #6410
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6410
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6686
Author: @freeb5d
Created: 9/29/2026
Status: ✅ Merged
Merged: 10/2/2026
Merged by: @MHSanaei
Base:
main← Head:fix/hot-apply-write-config📝 Commits (2)
43e3d69Write config.json after a hot applyb97420eTest that a hot apply refreshes config.json📊 Changes
4 files changed (+78 additions, -0 deletions)
View changed files
📝
internal/web/service/xray.go(+10 -0)➕
internal/web/service/xray_hot_apply_persist_test.go(+25 -0)📝
internal/xray/process.go(+16 -0)➕
internal/xray/process_persist_test.go(+27 -0)📄 Description
Fixes #6677
Problem
tryHotApplyreconciles the running core through the gRPC API and only updates the in-memory snapshot (SetConfig).Process.Start()is the only placebin/config.jsonis written, so after a hot-applied save the file stays stale until the next cold start. Anything that reads it directly, such as the Telegram and Discord config backups, sees old rules. (Saved settings are not lost on restart: the config is always rebuilt from the database.)Change
Process.PersistConfig()writes the current snapshot with the same atomic writeStart()uses.tryHotApplycalls it afterSetConfigon both success paths. A write failure is logged as a warning and does not restart the running core.TestPersistConfigWritesCurrentSnapshot.Testing
Not run: my environment has no C compiler for the SQLite driver. Files are gofmt-clean. Please rely on CI.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.