/
main.go
41 lines (33 loc) · 877 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
package main
import (
"flag"
"os"
"runtime/pprof"
"github.com/DDP-Projekt/DDPLS/ddpls"
"github.com/DDP-Projekt/DDPLS/log"
logging "github.com/tliron/commonlog"
// Must include a backend implementation. See kutil's logging/ for other options.
_ "github.com/tliron/commonlog/simple"
)
func main() {
var cpuprofile string
flag.StringVar(&cpuprofile, "cpuprofile", "", "write cpu profile to file")
flag.Parse()
// This increases logging verbosity (optional)
logging.Configure(1, nil)
ls := ddpls.NewDDPLS()
if cpuprofile != "" {
f, err := os.Create(cpuprofile)
if err != nil {
log.Warningf("error creating cpuprofile file: %w", err)
} else {
defer f.Close()
if err := pprof.StartCPUProfile(f); err != nil {
log.Warningf("error starting cpuprofile: %w", err)
} else {
defer pprof.StopCPUProfile()
}
}
}
ls.Server.RunStdio()
}