Add debugging option to codebase

This commit is contained in:
Tobie Morgan Hitchcock 2016-09-06 12:52:11 +01:00
parent f53a30130b
commit 94f5a72e26

21
main.go
View file

@ -14,8 +14,27 @@
package main package main
import "github.com/abcum/surreal/cli" import (
"os"
"github.com/pkg/profile"
"github.com/abcum/surreal/cli"
)
func main() { func main() {
switch os.Getenv("DEBUG") {
case "cpu":
defer profile.Start(profile.CPUProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop()
case "mem":
defer profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop()
case "block":
defer profile.Start(profile.BlockProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop()
case "trace":
defer profile.Start(profile.TraceProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop()
}
cli.Init() cli.Init()
} }