fix: config

pull/2997/head
icey-yu 9 months ago
parent 51fe509f79
commit 4963b8fd69

@ -216,19 +216,23 @@ func (cm *ConfigManager) resetConfig(c *gin.Context) {
} }
} }
ops := make([]clientv3.Op, 0)
for _, k := range changedKeys { for _, k := range changedKeys {
data, err := json.Marshal(configMap[k].new) data, err := json.Marshal(configMap[k].new)
if err != nil { if err != nil {
log.ZError(c, "marshal config failed", err) log.ZError(c, "marshal config failed", err)
continue continue
} }
txn = txn.Then(clientv3.OpPut(etcd.BuildKey(k), string(data))) ops = append(ops, clientv3.OpPut(etcd.BuildKey(k), string(data)))
} }
if len(ops) > 0 {
txn.Then(ops...)
_, err := txn.Commit() _, err := txn.Commit()
if err != nil { if err != nil {
log.ZError(c, "commit etcd txn failed", err) log.ZError(c, "commit etcd txn failed", err)
return return
} }
}
} }
func (cm *ConfigManager) Restart(c *gin.Context) { func (cm *ConfigManager) Restart(c *gin.Context) {

Loading…
Cancel
Save