Created
January 5, 2017 23:39
-
-
Save jessedearing/7f544238aee017a05eb1c526d932ffd1 to your computer and use it in GitHub Desktop.
Have go dump a stack trace on USR1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"os/signal" | |
"runtime/pprof" | |
"syscall" | |
) | |
func main() { | |
sigchan := make(chan os.Signal) | |
go func() { | |
for _ = range sigchan { | |
ps := pprof.Profiles() | |
for _, pro := range ps { | |
pro.WriteTo(os.Stderr, 2) | |
} | |
} | |
}() | |
signal.Notify(sigchan, syscall.SIGUSR1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment