-
Notifications
You must be signed in to change notification settings - Fork 15
/
esmeralda.go
66 lines (53 loc) · 1.21 KB
/
esmeralda.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"flag"
"fmt"
"net/http"
"os"
"path/filepath"
"runtime"
"runtime/trace"
_ "net/http/pprof"
"github.com/chuan-yun/esmeralda/server"
)
var (
commit = "N/A"
buildstamp = "N/A"
)
var (
isShowVersionInfo = flag.Bool("version", false, "output version information and exit")
isShowHelpInfo = flag.Bool("help", false, "output help information and exit")
profiling = flag.Bool("pprof", false, "Turn on pprof profiling")
profilingPort = flag.Int("pprof.port", 11011, "Define custom port for pprof profiling")
)
func main() {
flag.Parse()
if *isShowVersionInfo {
fmt.Println(filepath.Base(os.Args[0]))
fmt.Println("commit: " + commit + ", build: " + buildstamp)
fmt.Println("Copyright (c) 2017, chuanyun.io. All rights reserved.")
os.Exit(0)
}
if *isShowHelpInfo {
flag.Usage()
os.Exit(0)
}
if *profiling {
runtime.SetBlockProfileRate(1)
go func() {
http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", *profilingPort), nil)
}()
f, err := os.Create("trace.out")
if err != nil {
panic(err)
}
defer f.Close()
err = trace.Start(f)
if err != nil {
panic(err)
}
defer trace.Stop()
}
server := server.NewEsmeraldaServer()
server.Start()
}