Add pprof

This commit is contained in:
bodqhrohro 2020-01-13 17:31:28 +02:00
parent 48ac4fdcef
commit cfc9e1d522
2 changed files with 17 additions and 0 deletions

View file

@ -72,6 +72,10 @@ It is good idea to obtain Telegram API ID from [**https://my.telegram.org**](htt
... ...
``` ```
### Arguments ###
* `--profiling-port=xxxx`: starts the pprof server on port `xxxx`. Access is limited to localhost.
### How to receive files from Telegram ### ### How to receive files from Telegram ###
First of all, you need to set up web server that will serve some directory in your filesystem. First of all, you need to set up web server that will serve some directory in your filesystem.

View file

@ -1,6 +1,10 @@
package main package main
import ( import (
"flag"
"fmt"
"net/http"
_ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
@ -25,6 +29,15 @@ var cleanupDone chan struct{}
var sigintChannel chan os.Signal var sigintChannel chan os.Signal
func main() { func main() {
var profilingPort = flag.Int("profiling-port", 0, "The port for pprof server")
flag.Parse()
if *profilingPort > 0 {
go func() {
log.Println(http.ListenAndServe(fmt.Sprintf("localhost:%v", *profilingPort), nil))
}()
}
cleanupDone = make(chan struct{}) cleanupDone = make(chan struct{})
sigintChannel = make(chan os.Signal, 1) sigintChannel = make(chan os.Signal, 1)
signal.Notify(sigintChannel, os.Interrupt) signal.Notify(sigintChannel, os.Interrupt)