[refactor] all demo LogoutStartInfo

pull/130/head
q191201771 3 years ago
parent fdaf48528e
commit f8f3f64c54

@ -77,6 +77,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
url := parseFlag()
session := httpflv.NewPullSession()

@ -28,6 +28,7 @@ func main() {
option.Level = nazalog.LevelLogNothing
})
defer nazalog.Sync()
base.LogoutStartInfo()
urlTmpl, num := parseFlag()
urls := collect(urlTmpl, num)

@ -53,6 +53,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
var mu sync.Mutex
tagKey2writeTime := make(map[string]time.Time)

@ -202,6 +202,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
dataManager = datamanager.NewDataManager(datamanager.DmtMemory, config.ServerTimeoutSec)

@ -31,6 +31,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
var err error
flvFileName, aacFileName, avcFileName := parseFlag()

@ -40,6 +40,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
var err error
inFileName, outFileName := parseFlag()

@ -28,6 +28,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
url := parseFlag()
session := httpflv.NewPullSession()

@ -52,6 +52,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
urlTmpl, fileNameTmpl, num := parseFlag()
nazalog.Infof("parse flag succ. urlTmpl=%s, fileNameTmpl=%s, num=%d", urlTmpl, fileNameTmpl, num)

@ -25,6 +25,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
url, hlsOutPath, fragmentDurationMs, fragmentNum := parseFlag()
nazalog.Infof("parse flag succ. url=%s, hlsOutPath=%s, fragmentDurationMs=%d, fragmentNum=%d",

@ -15,6 +15,8 @@ import (
"strings"
"time"
"github.com/q191201771/lal/pkg/base"
"github.com/q191201771/naza/pkg/nazalog"
)
@ -23,6 +25,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
i := flag.String("i", "", "specify pull rtmp url")
o := flag.String("o", "", "specify push rtmp url list, separated by a comma")

@ -27,6 +27,7 @@ func main() {
_ = nazalog.Init(func(option *nazalog.Option) {
option.AssertBehavior = nazalog.AssertFatal
})
base.LogoutStartInfo()
inRtmpUrl, outRtspUrl, overTcp := parseFlag()

@ -26,6 +26,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
inUrl, outFilename, overTcp := parseFlag()

@ -27,6 +27,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
inUrl, outUrl, overTcp := parseFlag()

@ -163,6 +163,7 @@ func main() {
option.AssertBehavior = nazalog.AssertFatal
})
defer nazalog.Sync()
base.LogoutStartInfo()
inUrl, outUrl, pullOverTcp, pushOverTcp := parseFlag()

@ -53,6 +53,8 @@ var aliveSessionCount int32
func main() {
defer nazalog.Sync()
base.LogoutStartInfo()
filename, urlTmpl, num, isRecursive, logfile := parseFlag()
initLog(logfile)

@ -8,6 +8,40 @@
package base
import (
"os"
"strings"
"time"
"github.com/q191201771/naza/pkg/bininfo"
"github.com/q191201771/naza/pkg/nazalog"
)
// base包提供被其他多个package依赖的基础内容自身不依赖任何package
//
// TODO chef: 考虑部分内容放入关联的协议package的子package中
var startTime string
// ReadableNowTime
//
// TODO(chef): refactor 使用ReadableNowTime
//
func ReadableNowTime() string {
return time.Now().Format("2006-01-02 15:04:05.999")
}
func LogoutStartInfo() {
dir, _ := os.Getwd()
nazalog.Infof(" start: %s", startTime)
nazalog.Infof(" wd: %s", dir)
nazalog.Infof(" args: %s", strings.Join(os.Args, " "))
nazalog.Infof(" bininfo: %s", bininfo.StringifySingleLine())
nazalog.Infof(" version: %s", LalFullInfo)
nazalog.Infof(" github: %s", LalGithubSite)
nazalog.Infof(" doc: %s", LalDocSite)
}
func init() {
startTime = ReadableNowTime()
}

@ -13,7 +13,6 @@ import (
"math"
"net/http"
"os"
"strings"
"sync"
"time"
@ -59,21 +58,12 @@ type ServerManager struct {
func NewServerManager(confFile string, modOption ...ModOption) *ServerManager {
sm := &ServerManager{
serverStartTime: time.Now().Format("2006-01-02 15:04:05.999"),
exitChan: make(chan struct{}),
exitChan: make(chan struct{}, 1),
}
sm.groupManager = NewSimpleGroupManager(sm)
sm.config = LoadConfAndInitLog(confFile)
// TODO(chef): refactor 启动信息可以考虑放入package base中所有的app都打印
dir, _ := os.Getwd()
nazalog.Infof("wd: %s", dir)
nazalog.Infof("args: %s", strings.Join(os.Args, " "))
nazalog.Infof("bininfo: %s", bininfo.StringifySingleLine())
nazalog.Infof("version: %s", base.LalFullInfo)
nazalog.Infof("github: %s", base.LalGithubSite)
nazalog.Infof("doc: %s", base.LalDocSite)
nazalog.Infof("serverStartTime: %s", sm.serverStartTime)
base.LogoutStartInfo()
if sm.config.HlsConfig.Enable && sm.config.HlsConfig.UseMemoryAsDiskFlag {
nazalog.Infof("hls use memory as disk.")
@ -808,8 +798,6 @@ func (sm *ServerManager) serveHls(writer http.ResponseWriter, req *http.Request)
sm.hlsServerHandler.ServeHTTP(writer, req)
}
// ---------------------------------------------------------------------------------------------------------------------
func runWebPprof(addr string) {
nazalog.Infof("start web pprof listen. addr=%s", addr)

Loading…
Cancel
Save