add flag for pprof

This commit is contained in:
siddontang 2014-09-18 10:25:15 +08:00
parent f22bbb97df
commit fafd0c7e80
1 changed files with 8 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"flag"
"fmt"
"github.com/siddontang/ledisdb/config"
"github.com/siddontang/ledisdb/server"
"log"
@ -15,6 +16,8 @@ import (
var configFile = flag.String("config", "", "ledisdb config file")
var dbName = flag.String("db_name", "", "select a db to use, it will overwrite the config's db name")
var usePprof = flag.Bool("pprof", false, "enable pprof")
var pprofPort = flag.Int("pprof_port", 6060, "pprof http port")
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
@ -60,9 +63,11 @@ func main() {
app.Close()
}()
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
if *usePprof {
go func() {
log.Println(http.ListenAndServe(fmt.Sprintf(":%d", *pprofPort), nil))
}()
}
app.Run()
}