Monibuca / engine

Monibuca 核心引擎,包含流媒体核心转发逻辑,需要配合功能插件一起组合运行
MIT License
937 stars 199 forks source link

插件初始化的panic不会被检测到 #91

Closed Locter9001 closed 9 months ago

Locter9001 commented 9 months ago

我尝试在插件初始化时连接到数据库,数据库是一个MustConnect方法就是说连不上会panic但实际上这个panic并没有被monibuca捕获,初始化代码如下

func (conf *RecordConfig) OnEvent(event any) {
    switch v := event.(type) {
    case FirstConfig, config.Config:
        fmt.Println("录制插件正在准备初始化...")

        conf.Hls.Init()

        conf.db = sqlx.MustConnect("postgres", conf.Dsn)
        conf.rdb = redis.NewClient(&redis.Options{
            Addr:     conf.CacheConf.Addr,
            Password: conf.CacheConf.Psw,
        })

        fmt.Println("录制插件初始化成功")
    case SEpublish:
        streamPath := v.Target.Path

        go NewHLSRecorder().Start(streamPath)
    }
}

这个问题是在以代码方式启动monibuca时发现的,插件报错的原因是日志文件没有数据

langhuihui commented 9 months ago

初始化的 panic,monibuca 不会去捕获,就是应该暴露出来