-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
50 lines (38 loc) · 850 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"github.com/pjwerneck/bouncer/bouncermain"
_ "github.com/pjwerneck/bouncer/docs" // swagger docs
"flag"
"os"
"os/signal"
"runtime/pprof"
"github.com/rs/zerolog/log"
)
var (
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
versionFlag = flag.Bool("version", false, "print version information")
version = "dev"
)
func main() {
flag.Parse()
if *versionFlag {
fmt.Printf("Version: %s\n",
version)
return
}
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal().Err(err).Msg("could not create CPU profile")
}
defer f.Close()
pprof.StartCPUProfile(f)
}
go bouncermain.Main()
terminate := make(chan os.Signal, 1)
signal.Notify(terminate, os.Interrupt)
<-terminate
pprof.StopCPUProfile()
log.Printf("Server stopped")
}