add parameter pprofPort to configure the port of the pprof listener
This commit is contained in:
parent
fb0e900eb5
commit
a57f3d04a7
|
@ -60,6 +60,7 @@ type Conf struct {
|
|||
Metrics bool `yaml:"metrics"`
|
||||
MetricsPort int `yaml:"metricsPort"`
|
||||
Pprof bool `yaml:"pprof"`
|
||||
PprofPort int `yaml:"pprofPort"`
|
||||
RunOnConnect string `yaml:"runOnConnect"`
|
||||
RunOnConnectRestart bool `yaml:"runOnConnectRestart"`
|
||||
|
||||
|
@ -142,6 +143,10 @@ func (conf *Conf) fillAndCheck() error {
|
|||
conf.MetricsPort = 9998
|
||||
}
|
||||
|
||||
if conf.PprofPort == 0 {
|
||||
conf.MetricsPort = 9999
|
||||
}
|
||||
|
||||
if len(conf.Protocols) == 0 {
|
||||
conf.Protocols = []string{"udp", "tcp"}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,6 @@ import (
|
|||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
port = 9999
|
||||
)
|
||||
|
||||
// Parent is implemented by program.
|
||||
type Parent interface {
|
||||
Log(logger.Level, string, ...interface{})
|
||||
|
@ -30,9 +26,10 @@ type Pprof struct {
|
|||
// New allocates a Pprof.
|
||||
func New(
|
||||
listenIP string,
|
||||
port int,
|
||||
parent Parent,
|
||||
) (*Pprof, error) {
|
||||
address := listenIP + ":" + strconv.FormatInt(port, 10)
|
||||
address := listenIP + ":" + strconv.FormatInt(int64(port), 10)
|
||||
listener, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
4
main.go
4
main.go
|
@ -183,6 +183,7 @@ func (p *program) createResources(initial bool) error {
|
|||
if p.pprof == nil {
|
||||
p.pprof, err = pprof.New(
|
||||
p.conf.ListenIP,
|
||||
p.conf.PprofPort,
|
||||
p)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -303,7 +304,8 @@ func (p *program) closeResources(newConf *conf.Conf) {
|
|||
closePprof := false
|
||||
if newConf == nil ||
|
||||
newConf.Pprof != p.conf.Pprof ||
|
||||
newConf.ListenIP != p.conf.ListenIP {
|
||||
newConf.ListenIP != p.conf.ListenIP ||
|
||||
newConf.PprofPort != p.conf.PprofPort {
|
||||
closePprof = true
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,10 @@ metrics: no
|
|||
# port of the metrics listener.
|
||||
metricsPort: 9998
|
||||
|
||||
# enable pprof on port 9999 to monitor performances.
|
||||
# enable pprof to monitor performances.
|
||||
pprof: no
|
||||
# port of the pprof listener.
|
||||
pprofPort: 9999
|
||||
|
||||
# command to run when a client connects to the server.
|
||||
# this is terminated with SIGINT when a client disconnects from the server.
|
||||
|
|
Loading…
Reference in New Issue