mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-06 13:15:01 +03:00
Write config.json after a hot apply (#6686)
* Write config.json after a hot apply tryHotApply only updated the in-memory snapshot, so bin/config.json stayed stale until the next cold start and the Telegram/Discord config backups uploaded old rules. Persist the new config once the API calls succeed; a write failure is logged and does not restart the running core. * Test that a hot apply refreshes config.json
This commit is contained in:
@@ -316,6 +316,22 @@ func (p *Process) SetConfig(config *Config) {
|
||||
p.config = config
|
||||
}
|
||||
|
||||
// PersistConfig writes the current configuration snapshot to the config file,
|
||||
// keeping it in step after a hot apply (Start only writes it on a cold start).
|
||||
func (p *Process) PersistConfig() error {
|
||||
p.mu.RLock()
|
||||
data, err := json.MarshalIndent(p.config, "", " ")
|
||||
path := p.configPath
|
||||
p.mu.RUnlock()
|
||||
if err != nil {
|
||||
return common.NewErrorf("Failed to generate XRAY configuration files: %v", err)
|
||||
}
|
||||
if path == "" {
|
||||
path = GetConfigPath()
|
||||
}
|
||||
return writeFileAtomic(path, data, 0o600)
|
||||
}
|
||||
|
||||
// GetOnlineClients returns the union of locally-online clients and
|
||||
// node-online clients from every registered remote panel. Dedupes by
|
||||
// email so a client connected to both a local and a node-managed inbound
|
||||
|
||||
Reference in New Issue
Block a user