-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (42 loc) · 788 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
51
package main
import (
"log"
"os"
"runtime/pprof"
"github.com/aureliano/db-unit-extractor/cmd"
_ "github.com/sijms/go-ora/v2"
)
func main() {
cpuProfile := os.Getenv("CPU_PROFILE")
var file *os.File
var err error
if cpuProfile != "" {
file, err = os.Create(cpuProfile)
if err != nil {
log.Fatal(err)
}
if err = pprof.StartCPUProfile(file); err != nil {
log.Fatal(err)
}
}
memProfile := os.Getenv("MEM_PROFILE")
if memProfile != "" {
file, err = os.Create(memProfile)
if err != nil {
log.Fatal(err)
}
if err = pprof.WriteHeapProfile(file); err != nil {
log.Fatal(err)
}
}
err = cmd.NewRootCommand().Execute()
if cpuProfile != "" {
pprof.StopCPUProfile()
}
if file != nil {
_ = file.Close()
}
if err != nil {
os.Exit(1)
}
}