mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
add profiler support
profiling is now available via the HTTP base URL /debug/pprof/ examples, use this URL to start and download a 30 seconds CPU profile: /debug/pprof/profile?seconds=30 use this URL to profile used memory: /debug/pprof/heap?gc=1 use this URL to profile allocated memory: /debug/pprof/allocs?gc=1 Full docs here: https://golang.org/pkg/net/http/pprof/
This commit is contained in:
@@ -30,6 +30,7 @@ const (
|
||||
dumpDataPath = "/api/v1/dumpdata"
|
||||
loadDataPath = "/api/v1/loaddata"
|
||||
metricsPath = "/metrics"
|
||||
pprofBasePath = "/debug"
|
||||
webBasePath = "/web"
|
||||
webUsersPath = "/web/users"
|
||||
webUserPath = "/web/user"
|
||||
@@ -85,7 +86,7 @@ func SetDataProvider(provider dataprovider.Provider) {
|
||||
}
|
||||
|
||||
// Initialize the HTTP server
|
||||
func (c Conf) Initialize(configDir string) error {
|
||||
func (c Conf) Initialize(configDir string, profiler bool) error {
|
||||
var err error
|
||||
logger.Debug(logSender, "", "initializing HTTP server with config %+v", c)
|
||||
backupsPath = getConfigPath(c.BackupsPath, configDir)
|
||||
@@ -103,7 +104,7 @@ func (c Conf) Initialize(configDir string) error {
|
||||
certificateFile := getConfigPath(c.CertificateFile, configDir)
|
||||
certificateKeyFile := getConfigPath(c.CertificateKeyFile, configDir)
|
||||
loadTemplates(templatesPath)
|
||||
initializeRouter(staticFilesPath)
|
||||
initializeRouter(staticFilesPath, profiler)
|
||||
httpServer := &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%d", c.BindAddress, c.BindPort),
|
||||
Handler: router,
|
||||
|
||||
Reference in New Issue
Block a user