Added flag for pprof and debug make target.

This commit is contained in:
empathetic-alligator 2014-12-14 20:37:20 -05:00
parent b81324a5b4
commit 3dac036edf
2 changed files with 15 additions and 2 deletions

View File

@ -24,5 +24,9 @@ $(KEY):
run: $(BINARY) $(KEY)
./$(BINARY) -i $(KEY) --bind ":$(PORT)" -vv
debug: $(BINARY) $(KEY)
./$(BINARY) --pprof 6060 -i $(KEY) --bind ":$(PORT)" -vv
test:
go test .
go test .

11
cmd.go
View File

@ -7,13 +7,16 @@ import (
"os"
"os/signal"
"strings"
"net/http"
"github.com/alexcesaro/log"
"github.com/alexcesaro/log/golog"
"github.com/jessevdk/go-flags"
)
import _ "net/http/pprof"
// Options contains the flag options
type Options struct {
Verbose []bool `short:"v" long:"verbose" description:"Show verbose logging."`
Identity string `short:"i" long:"identity" description:"Private key to identify server with." default:"~/.ssh/id_rsa"`
@ -21,6 +24,7 @@ type Options struct {
Admin []string `long:"admin" description:"Fingerprint of pubkey to mark as admin."`
Whitelist string `long:"whitelist" description:"Optional file of pubkey fingerprints that are allowed to connect"`
Motd string `long:"motd" description:"Message of the Day file (optional)"`
Pprof int `long:"pprof" description:"enable http server for pprof"`
}
var logLevels = []log.Level{
@ -32,7 +36,6 @@ var logLevels = []log.Level{
func main() {
options := Options{}
parser := flags.NewParser(&options, flags.Default)
p, err := parser.Parse()
if err != nil {
if p == nil {
@ -41,6 +44,12 @@ func main() {
return
}
if options.Pprof != 0 {
go func(){
fmt.Println(http.ListenAndServe(fmt.Sprintf("localhost:%d", options.Pprof), nil))
}()
}
// Initialize seed for random colors
RandomColorInit()