Print runtime stats every minute when --debug flag is set
This commit is contained in:
parent
8c605dcd96
commit
e1684fc8c0
4
main.go
4
main.go
@ -203,6 +203,10 @@ func main() {
|
|||||||
gin.SetMode("release")
|
gin.SetMode("release")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.Debug {
|
||||||
|
go startRuntimeProfiler()
|
||||||
|
}
|
||||||
|
|
||||||
startServer()
|
startServer()
|
||||||
openPage()
|
openPage()
|
||||||
handleSignals()
|
handleSignals()
|
||||||
|
22
utils.go
Normal file
22
utils.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"runtime"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func startRuntimeProfiler() {
|
||||||
|
m := &runtime.MemStats{}
|
||||||
|
|
||||||
|
for {
|
||||||
|
runtime.ReadMemStats(m)
|
||||||
|
|
||||||
|
fmt.Println("-----------------------")
|
||||||
|
fmt.Println("Goroutines:", runtime.NumGoroutine())
|
||||||
|
fmt.Println("Memory acquired:", m.Sys)
|
||||||
|
fmt.Println("Memory used:", m.Alloc)
|
||||||
|
|
||||||
|
time.Sleep(time.Minute)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user