CPU profiling (#1371)

* Add cpuprofile flag
* Add notes to readme
This commit is contained in:
WithoutPants
2021-05-16 17:21:11 +10:00
committed by GitHub
parent bc9aa02835
commit 16fe21138f
5 changed files with 59 additions and 5 deletions

14
main.go
View File

@@ -2,6 +2,11 @@
package main
import (
"os"
"os/signal"
"runtime/pprof"
"syscall"
"github.com/stashapp/stash/pkg/api"
"github.com/stashapp/stash/pkg/manager"
@@ -12,9 +17,16 @@ import (
func main() {
manager.Initialize()
api.Start()
// stop any profiling at exit
defer pprof.StopCPUProfile()
blockForever()
}
func blockForever() {
select {}
// handle signals
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
<-signals
}