mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-14 16:17:17 +03:00
Merge pull request #53 from empathetic-alligator/master
Added flag for pprof and debug make target.
This commit is contained in:
commit
9a00714632
6
Makefile
6
Makefile
@ -24,5 +24,9 @@ $(KEY):
|
|||||||
run: $(BINARY) $(KEY)
|
run: $(BINARY) $(KEY)
|
||||||
./$(BINARY) -i $(KEY) --bind ":$(PORT)" -vv
|
./$(BINARY) -i $(KEY) --bind ":$(PORT)" -vv
|
||||||
|
|
||||||
|
debug: $(BINARY) $(KEY)
|
||||||
|
./$(BINARY) --pprof 6060 -i $(KEY) --bind ":$(PORT)" -vv
|
||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test .
|
go test .
|
10
cmd.go
10
cmd.go
@ -7,11 +7,13 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/alexcesaro/log"
|
"github.com/alexcesaro/log"
|
||||||
"github.com/alexcesaro/log/golog"
|
"github.com/alexcesaro/log/golog"
|
||||||
"github.com/jessevdk/go-flags"
|
"github.com/jessevdk/go-flags"
|
||||||
)
|
)
|
||||||
|
import _ "net/http/pprof"
|
||||||
|
|
||||||
// Options contains the flag options
|
// Options contains the flag options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
@ -21,6 +23,7 @@ type Options struct {
|
|||||||
Admin []string `long:"admin" description:"Fingerprint of pubkey to mark as admin."`
|
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"`
|
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)"`
|
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{
|
var logLevels = []log.Level{
|
||||||
@ -32,7 +35,6 @@ var logLevels = []log.Level{
|
|||||||
func main() {
|
func main() {
|
||||||
options := Options{}
|
options := Options{}
|
||||||
parser := flags.NewParser(&options, flags.Default)
|
parser := flags.NewParser(&options, flags.Default)
|
||||||
|
|
||||||
p, err := parser.Parse()
|
p, err := parser.Parse()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if p == nil {
|
if p == nil {
|
||||||
@ -41,6 +43,12 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.Pprof != 0 {
|
||||||
|
go func(){
|
||||||
|
fmt.Println(http.ListenAndServe(fmt.Sprintf("localhost:%d", options.Pprof), nil))
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize seed for random colors
|
// Initialize seed for random colors
|
||||||
RandomColorInit()
|
RandomColorInit()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user