1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-25 09:36:24 -07:00

Properly create plugins table on startup, close Lua state on end

This commit is contained in:
Eggbertx 2022-12-29 16:58:49 -08:00
parent a0a3ed46c8
commit c38816b5df
2 changed files with 8 additions and 2 deletions

View file

@ -30,9 +30,9 @@ var (
func main() {
defer func() {
fmt.Println("Cleaning up")
//gcsql.ExecSQL("DROP TABLE DBPREFIXsessions")
gcsql.Close()
gcutil.CloseLog()
gcplugin.ClosePlugins()
}()
fmt.Printf("Starting gochan v%s\n", versionStr)

View file

@ -19,6 +19,12 @@ func initLua() {
}
}
func ClosePlugins() {
if lState != nil {
lState.Close()
}
}
func createLuaLogFunc(which string) lua.LGFunction {
return func(l *lua.LState) int {
args := []interface{}{}
@ -65,7 +71,7 @@ func LoadPlugins(paths []string) error {
if err = lState.DoFile(pluginPath); err != nil {
return err
}
pluginTable := lState.CheckTable(-1)
pluginTable := lState.NewTable()
pluginTable.ForEach(func(key, val lua.LValue) {
keyStr := key.String()
fn, ok := val.(*lua.LFunction)