mirror of
https://github.com/restic/rest-server.git
synced 2025-12-07 09:36:13 -08:00
Introduce cpuprofile argument
This commit is contained in:
12
server.go
12
server.go
@@ -7,14 +7,26 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime/pprof"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var cpuprofile = flag.String("cpuprofile", "", "write CPU profile to file")
|
||||
var listen = flag.String("listen", ":8000", "listen address")
|
||||
var path = flag.String("path", "/tmp/restic", "data directory")
|
||||
var tls = flag.Bool("tls", false, "turn on TLS support")
|
||||
flag.Parse()
|
||||
|
||||
if *cpuprofile != "" {
|
||||
f, err := os.Create(*cpuprofile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Println("CPU profiling enabled")
|
||||
pprof.StartCPUProfile(f)
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
log.Println("Creating repository directories")
|
||||
dirs := []string{
|
||||
"data",
|
||||
|
||||
Reference in New Issue
Block a user