From 583e3320bdcfb9d738d0ea82348c7978d08246a6 Mon Sep 17 00:00:00 2001 From: qydysky Date: Thu, 10 Aug 2023 21:38:51 +0800 Subject: [PATCH] =?utf8?q?Add=20=E6=B7=BB=E5=8A=A0debug=E6=A8=A1=E5=BC=8F?= =?utf8?q?=EF=BC=8Cfmp4=E4=B8=8Bm4s=E6=B1=A0=E7=9A=84=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- Reply/stream.go | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0422f96..5af53d1 100644 --- a/README.md +++ b/README.md @@ -238,7 +238,10 @@ config_K_v.json } ``` -另外,当配置文件中的`debug模式`为`true`时,标准包[net/http/pprof](https://pkg.go.dev/net/http/pprof)将在`/debug/pprof/`路径可用,从而可以使用`go tool pprof`工具进行性能调试。 +另外,当配置文件中的`debug模式`为`true`时 + +- 标准包[net/http/pprof](https://pkg.go.dev/net/http/pprof)将在`/debug/pprof/`路径可用,从而可以使用`go tool pprof`工具进行性能调试。 +- 当录制fmp4时,每1分钟打印m4s池状态 #### 自定义config_K_v.json diff --git a/Reply/stream.go b/Reply/stream.go index 228402d..56d8c79 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -862,8 +862,23 @@ func (t *M4SStream) saveStreamFlv() (e error) { func (t *M4SStream) saveStreamM4s() (e error) { // 同时下载数限制 - var download_limit = &funcCtrl.BlockFuncN{ - Max: 3, + var download_limit = &funcCtrl.BlockFuncN{Max: 3} + + if v, ok := t.common.K_v.LoadV(`debug模式`).(bool); ok && v { + ctx, can := context.WithCancel(context.Background()) + defer can() + go func() { + ticker := time.NewTicker(time.Minute) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + } + t.log.L(`T: `, fmt.Sprintf("m4sPoolState pooled(%d), nopooled(%d), inuse(%d), nouse(%d), sum(%d)", t.m4s_pool.PoolState()...)) + } + }() } // @@ -1462,7 +1477,7 @@ func (t *M4SStream) PusherToHttp(conn net.Conn, w http.ResponseWriter, r *http.R done := time.AfterFunc(time.Second, func() { cancelRec() if conn != nil { - println(conn.Close()) + conn.Close() } }).Stop defer done() -- 2.39.2