配置重载优化

This commit is contained in:
hahwu 2025-01-02 16:08:26 +08:00
parent db575f5bc0
commit e6a87a6c04
2 changed files with 23 additions and 8 deletions

View File

@ -51,6 +51,13 @@ func init() {
}
func Reload() {
for k := range G_AllConfigsJsonData {
InitCfg(k)
log.Debug("配置已重新加载:%s", k)
}
}
func readRfNew(st interface{}, ralativePath string) *recordfile.RecordFile {
rf, err := recordfile.New(st)
if err != nil {

View File

@ -1,12 +1,12 @@
package leaf
import (
"fmt"
"os"
"os/signal"
mergeCluster "server/cluster"
sconf "server/conf"
"server/game"
"server/gamedata"
"server/pkg/github.com/name5566/leaf/cluster"
"server/pkg/github.com/name5566/leaf/conf"
"server/pkg/github.com/name5566/leaf/console"
@ -45,11 +45,19 @@ func Run(mods ...module.Module) {
// close
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL)
sig := <-c
fmt.Printf("Leaf closing down (signal: %v)\n", sig.String())
console.Destroy()
cluster.Destroy()
module.Destroy()
game.Destroy()
signal.Notify(c, syscall.SIGTERM, syscall.SIGINT)
for {
sig := <-c
if sig == syscall.SIGINT {
gamedata.Reload()
continue
}
log.Debug("Leaf closing down (signal: %v)\n", sig.String())
console.Destroy()
cluster.Destroy()
module.Destroy()
game.Destroy()
os.Exit(1)
}
}