diff options
-rw-r--r-- | hydra.go | 10 | ||||
-rw-r--r-- | os_nonunix.go | 7 | ||||
-rw-r--r-- | os_unix.go | 21 |
3 files changed, 29 insertions, 9 deletions
@@ -5,7 +5,6 @@ import ( "github.com/yuin/gopher-lua" "os" "os/signal" - "runtime/pprof" "syscall" "time" ) @@ -73,14 +72,7 @@ func main() { signalChannel = make(chan os.Signal, 1) signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP) - go func() { - ch := make(chan os.Signal, 1) - signal.Notify(ch, syscall.SIGUSR1) - for { - <-ch - pprof.Lookup("goroutine").WriteTo(os.Stdout, 1) - } - }() + backtrace_listen() l := lua.NewState() defer l.Close() diff --git a/os_nonunix.go b/os_nonunix.go new file mode 100644 index 0000000..c5a7133 --- /dev/null +++ b/os_nonunix.go @@ -0,0 +1,7 @@ +//go:build !linux && !openbsd && !freebsd && !netbsd && !dragonfly && !solaris && !darwin && !aix + +package main + +func backtrace_listen() { + +} diff --git a/os_unix.go b/os_unix.go new file mode 100644 index 0000000..5afe392 --- /dev/null +++ b/os_unix.go @@ -0,0 +1,21 @@ +//go:build linux || openbsd || freebsd || netbsd || dragonfly || solaris || darwin || aix + +package main + +import ( + "os" + "os/signal" + "runtime/pprof" + "syscall" +) + +func backtrace_listen() { + go func() { + ch := make(chan os.Signal, 1) + signal.Notify(ch, syscall.SIGUSR1) + for { + <-ch + pprof.Lookup("goroutine").WriteTo(os.Stdout, 1) + } + }() +} |