fix(lua): enable file watch by default for hot reload

EnableFileWatch was false by default (Go bool zero value) when
global_settings was not configured. Now defaults to true to enable
Lua script hot reload without server restart.

Also fix indentation in init.go default value settings.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-09 13:45:55 +08:00
parent 8f3c304837
commit 986ebdf207

View File

@ -140,13 +140,16 @@ func initLuaEngine(luaCfg *config.LuaMiddlewareConfig) (*lua.LuaEngine, error) {
}
if engineCfg.MaxExecutionTime == 0 {
engineCfg.MaxExecutionTime = 30 * time.Second
}
if engineCfg.LStatePoolInitialSize == 0 {
engineCfg.LStatePoolInitialSize = 100
}
if engineCfg.LStatePoolMaxSize == 0 {
engineCfg.LStatePoolMaxSize = 1000
}
if engineCfg.LStatePoolInitialSize == 0 {
engineCfg.LStatePoolInitialSize = 100
}
if engineCfg.LStatePoolMaxSize == 0 {
engineCfg.LStatePoolMaxSize = 1000
}
// EnableFileWatch 默认启用(用于 Lua 脚本热更新)
// 由于 bool 零值是 false当配置未设置时默认启用文件监控
engineCfg.EnableFileWatch = true
engine, err := lua.NewEngine(engineCfg)
if err != nil {