mirror of
https://github.com/restic/rest-server.git
synced 2026-09-25 21:41:25 -07:00
Introduce cpuprofile argument
This commit is contained in:
@@ -7,14 +7,26 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime/pprof"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var cpuprofile = flag.String("cpuprofile", "", "write CPU profile to file")
|
||||||
var listen = flag.String("listen", ":8000", "listen address")
|
var listen = flag.String("listen", ":8000", "listen address")
|
||||||
var path = flag.String("path", "/tmp/restic", "data directory")
|
var path = flag.String("path", "/tmp/restic", "data directory")
|
||||||
var tls = flag.Bool("tls", false, "turn on TLS support")
|
var tls = flag.Bool("tls", false, "turn on TLS support")
|
||||||
flag.Parse()
|
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")
|
log.Println("Creating repository directories")
|
||||||
dirs := []string{
|
dirs := []string{
|
||||||
"data",
|
"data",
|
||||||
|
|||||||
Reference in New Issue
Block a user