Skip to content

Commit

Permalink
pprof: change capitalization
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Mar 27, 2021
1 parent a57f3d0 commit c40fdba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down Expand Up @@ -143,7 +143,7 @@ func (conf *Conf) fillAndCheck() error {
conf.MetricsPort = 9998
}

if conf.PprofPort == 0 {
if conf.PPROFPort == 0 {
conf.MetricsPort = 9999
}

Expand Down
16 changes: 8 additions & 8 deletions internal/pprof/pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand All @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion rtsp-simple-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c40fdba

Please sign in to comment.