-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
49 lines (41 loc) · 1014 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
//#!go build github.com/cho45/go-KX3-panadapter/{kx3hq,panadapter} && go run
package main
import (
"flag"
"fmt"
"github.com/cho45/go-KX3-panadapter/panadapter"
"log"
"os"
"runtime"
"runtime/pprof"
)
func main() {
var numcpu int
var configPath string
var cpuprofile string
flag.IntVar(&numcpu, "numcpu", runtime.NumCPU(), "cpu num (default = runtime.NumCPU())")
flag.StringVar(&configPath, "config", "config.json", "path to config.json")
flag.StringVar(&cpuprofile, "cpuprofile", "", "write cpu profile to file")
flag.Parse()
if cpuprofile != "" {
f, err := os.Create(cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
runtime.GOMAXPROCS(numcpu)
config, err := panadapter.ReadConfig(configPath)
if err != nil {
fmt.Printf("Error on reading config: %s", err)
os.Exit(255)
}
server := &panadapter.Server{Config: config}
server.Init()
err = server.Start()
if err != nil {
fmt.Printf("Error", err)
os.Exit(255)
}
}