Skip to content

Commit a5fb94e

Browse files
authored
Refactor pprof flag handling and cleanup imports (#176)
Moved the pprof flag definition to use flag.StringVar with svc.DebugAddr and removed unused pprof-related imports and code from run.go. This streamlines flag management and eliminates unnecessary code.
1 parent 90ff510 commit a5fb94e

2 files changed

Lines changed: 1 addition & 8 deletions

File tree

service/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ var (
2222
status = flag.String("status", "", "Path to status file")
2323
keep = flag.Int("keep", 100, "Count of status files")
2424
debug = flag.Bool("debug", false, "debug")
25-
pprof = flag.String("pprof", "", "pprof port")
2625
)
2726

2827
const commonFlag = `
@@ -108,6 +107,7 @@ func main() {
108107
flag.Usage = func() {
109108
fmt.Fprintf(flag.CommandLine.Output(), `Usage of %s:%s%s%s%s`, os.Args[0], commonFlag, serverFlag, clientFlag, svc.Usage())
110109
}
110+
flag.StringVar(&svc.DebugAddr, "pprof", "", "pprof port")
111111
flag.StringVar(&svc.Options.UpdateURL, "update", "", "Update URL")
112112
flags.SetConfigFile(filepath.Join(filepath.Dir(self), "config.ini"))
113113
flags.Parse()

service/run.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package main
22

33
import (
44
"net"
5-
"net/http"
6-
_ "net/http/pprof"
75
"net/url"
86
"strconv"
97

@@ -21,11 +19,6 @@ type Runner interface {
2119
}
2220

2321
func run() error {
24-
if addr := *pprof; addr != "" {
25-
go func() {
26-
svc.Print(http.ListenAndServe(addr, nil))
27-
}()
28-
}
2922
base := NewBase(*host, *port)
3023
base.ErrorLog = errorLogger.Logger
3124
servers := []*httpsvr.Server{base.Server}

0 commit comments

Comments
 (0)