pprof: change capitalization

This commit is contained in:
aler9 2021-03-27 12:23:19 +01:00
parent a57f3d04a7
commit c40fdbae7c
4 changed files with 20 additions and 20 deletions

View File

@ -59,8 +59,8 @@ type Conf struct {
ReadBufferCount int `yaml:"readBufferCount"`
Metrics bool `yaml:"metrics"`
MetricsPort int `yaml:"metricsPort"`
Pprof bool `yaml:"pprof"`
PprofPort int `yaml:"pprofPort"`
PPROF bool `yaml:"pprof"`
PPROFPort int `yaml:"pprofPort"`
RunOnConnect string `yaml:"runOnConnect"`
RunOnConnectRestart bool `yaml:"runOnConnectRestart"`
@ -143,7 +143,7 @@ func (conf *Conf) fillAndCheck() error {
conf.MetricsPort = 9998
}
if conf.PprofPort == 0 {
if conf.PPROFPort == 0 {
conf.MetricsPort = 9999
}

View File

@ -17,25 +17,25 @@ type Parent interface {
Log(logger.Level, string, ...interface{})
}
// Pprof is a performance metrics exporter.
type Pprof struct {
// PPROF is a performance metrics exporter.
type PPROF struct {
listener net.Listener
server *http.Server
}
// New allocates a Pprof.
// New allocates a PPROF.
func New(
listenIP string,
port int,
parent Parent,
) (*Pprof, error) {
) (*PPROF, error) {
address := listenIP + ":" + strconv.FormatInt(int64(port), 10)
listener, err := net.Listen("tcp", address)
if err != nil {
return nil, err
}
pp := &Pprof{
pp := &PPROF{
listener: listener,
}
@ -49,12 +49,12 @@ func New(
return pp, nil
}
// Close closes a Pprof.
func (pp *Pprof) Close() {
// Close closes a PPROF.
func (pp *PPROF) Close() {
pp.server.Shutdown(context.Background())
}
func (pp *Pprof) run() {
func (pp *PPROF) run() {
err := pp.server.Serve(pp.listener)
if err != http.ErrServerClosed {
panic(err)

16
main.go
View File

@ -31,7 +31,7 @@ type program struct {
stats *stats.Stats
logger *logger.Logger
metrics *metrics.Metrics
pprof *pprof.Pprof
pprof *pprof.PPROF
serverRTSPPlain *serverrtsp.Server
serverRTSPTLS *serverrtsp.Server
serverRTMP *serverrtmp.Server
@ -179,11 +179,11 @@ func (p *program) createResources(initial bool) error {
}
}
if p.conf.Pprof {
if p.conf.PPROF {
if p.pprof == nil {
p.pprof, err = pprof.New(
p.conf.ListenIP,
p.conf.PprofPort,
p.conf.PPROFPort,
p)
if err != nil {
return err
@ -301,12 +301,12 @@ func (p *program) closeResources(newConf *conf.Conf) {
closeMetrics = true
}
closePprof := false
closePPROF := false
if newConf == nil ||
newConf.Pprof != p.conf.Pprof ||
newConf.PPROF != p.conf.PPROF ||
newConf.ListenIP != p.conf.ListenIP ||
newConf.PprofPort != p.conf.PprofPort {
closePprof = true
newConf.PPROFPort != p.conf.PPROFPort {
closePPROF = true
}
closeServerPlain := false
@ -406,7 +406,7 @@ func (p *program) closeResources(newConf *conf.Conf) {
p.serverRTSPPlain = nil
}
if closePprof && p.pprof != nil {
if closePPROF && p.pprof != nil {
p.pprof.Close()
p.pprof = nil
}

View File

@ -25,7 +25,7 @@ metrics: no
# port of the metrics listener.
metricsPort: 9998
# enable pprof to monitor performances.
# enable pprof-compatible endpoint to monitor performances.
pprof: no
# port of the pprof listener.
pprofPort: 9999