Files
2026-08-21 20:24:36 -04:00

39 lines
668 B
Go

package server
import (
"net/http"
_ "net/http/pprof"
"os"
"runtime"
"runtime/debug"
"github.com/AvengeMedia/DankMaterialShell/core/internal/log"
)
const (
serverMaxProcs = 4
serverGCPercent = 50
)
func tuneRuntime() {
if os.Getenv("GOMAXPROCS") == "" {
runtime.GOMAXPROCS(min(runtime.NumCPU(), serverMaxProcs))
}
if os.Getenv("GOGC") == "" {
debug.SetGCPercent(serverGCPercent)
}
}
func startPprof() {
addr := os.Getenv("DMS_PPROF")
if addr == "" {
return
}
go func() {
log.Infof("pprof listening on http://%s/debug/pprof/", addr)
if err := http.ListenAndServe(addr, nil); err != nil {
log.Warnf("pprof server: %v", err)
}
}()
}