Compare commits
1 Commits
main
...
memory_pro
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5360b0074 |
@ -19,6 +19,8 @@ COPY --from=builder /go/src/app/corso /corso
|
|||||||
# Pull tls certs directly from latest upstream image
|
# Pull tls certs directly from latest upstream image
|
||||||
COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|
||||||
|
RUN apk add --no-cache --update binutils util-linux logrotate
|
||||||
|
|
||||||
ENV CORSO_HOME=/app/corso
|
ENV CORSO_HOME=/app/corso
|
||||||
ENV CORSO_CONFIG_DIR=$CORSO_HOME \
|
ENV CORSO_CONFIG_DIR=$CORSO_HOME \
|
||||||
KOPIA_CONFIG_PATH=$CORSO_HOME/kopia/config/repository.config \
|
KOPIA_CONFIG_PATH=$CORSO_HOME/kopia/config/repository.config \
|
||||||
@ -28,4 +30,4 @@ ENV CORSO_CONFIG_DIR=$CORSO_HOME \
|
|||||||
KOPIA_PERSIST_CREDENTIALS_ON_CONNECT=false \
|
KOPIA_PERSIST_CREDENTIALS_ON_CONNECT=false \
|
||||||
KOPIA_CHECK_FOR_UPDATES=false
|
KOPIA_CHECK_FOR_UPDATES=false
|
||||||
|
|
||||||
ENTRYPOINT ["/corso"]
|
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
||||||
|
|||||||
@ -2,8 +2,11 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
|
"runtime/pprof"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -95,6 +98,16 @@ func Handle() {
|
|||||||
ctx, log := logger.Seed(ctx, logger.PreloadLogLevel())
|
ctx, log := logger.Seed(ctx, logger.PreloadLogLevel())
|
||||||
defer func() {
|
defer func() {
|
||||||
_ = log.Sync() // flush all logs in the buffer
|
_ = log.Sync() // flush all logs in the buffer
|
||||||
|
f, err := os.Create("mem.prof")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("could not create memory profile: ", err)
|
||||||
|
}
|
||||||
|
defer f.Close() // error handling omitted for example
|
||||||
|
runtime.GC() // get up-to-date statistics
|
||||||
|
if err := pprof.WriteHeapProfile(f); err != nil {
|
||||||
|
log.Fatal("could not write memory profile: ", err)
|
||||||
|
}
|
||||||
|
PrintMemUsage()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := corsoCmd.ExecuteContext(ctx); err != nil {
|
if err := corsoCmd.ExecuteContext(ctx); err != nil {
|
||||||
@ -113,3 +126,17 @@ func indentExamplesTemplate(template string) string {
|
|||||||
|
|
||||||
return e.ReplaceAllString(template, "{{.Example | indent 2}}")
|
return e.ReplaceAllString(template, "{{.Example | indent 2}}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PrintMemUsage() {
|
||||||
|
var m runtime.MemStats
|
||||||
|
runtime.ReadMemStats(&m)
|
||||||
|
// For info on each, see: https://golang.org/pkg/runtime/#MemStats
|
||||||
|
fmt.Printf("Alloc = %v MiB", bToMb(m.Alloc))
|
||||||
|
fmt.Printf("\tTotalAlloc = %v MiB", bToMb(m.TotalAlloc))
|
||||||
|
fmt.Printf("\tSys = %v MiB", bToMb(m.Sys))
|
||||||
|
fmt.Printf("\tNumGC = %v\n", m.NumGC)
|
||||||
|
}
|
||||||
|
|
||||||
|
func bToMb(b uint64) uint64 {
|
||||||
|
return b / 1024 / 1024
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user