Skip to content

Commit

Permalink
move -monitoring_listen listener into the namespace child process
Browse files Browse the repository at this point in the history
This makes CPU profiling capture the process doing actual work.
  • Loading branch information
stapelberg committed Sep 3, 2021
1 parent 714d767 commit a8b8b0c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cmd/gokr-rsyncd/rsyncd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ func rsyncdMain() error {
"<modulename>=<path> pairs for quick setup of the server, without a config file")

flag.Parse()
if *monitoringListen != "" {
go func() {
log.Printf("HTTP server for monitoring listening on http://%s/debug/pprof", *monitoringListen)
if err := http.ListenAndServe(*monitoringListen, nil); err != nil {
log.Printf("-monitoring_listen: %v", err)
}
}()
}
var modMap map[string]rsyncd.Module
if *moduleMap != "" {
parts := strings.Split(*moduleMap, "=")
Expand All @@ -73,6 +65,16 @@ func rsyncdMain() error {

log.Printf("rsync module %q with path %s configured", name, mod.Path)
}

if *monitoringListen != "" {
go func() {
log.Printf("HTTP server for monitoring listening on http://%s/debug/pprof", *monitoringListen)
if err := http.ListenAndServe(*monitoringListen, nil); err != nil {
log.Printf("-monitoring_listen: %v", err)
}
}()
}

srv := &rsyncd.Server{Modules: modMap}
var ln net.Listener
if listeners, err := activation.Listeners(); err == nil && len(listeners) > 0 {
Expand Down

0 comments on commit a8b8b0c

Please sign in to comment.