Display memory usage and some metrics in logs

This commit is contained in:
Frédéric Guillot 2018-04-14 14:23:05 -07:00
parent 4cdb2f820b
commit 45dde0cf4a
2 changed files with 12 additions and 2 deletions

View File

@ -8,10 +8,9 @@ import (
"flag"
"fmt"
"github.com/miniflux/miniflux/logger"
"github.com/miniflux/miniflux/config"
"github.com/miniflux/miniflux/daemon"
"github.com/miniflux/miniflux/logger"
"github.com/miniflux/miniflux/storage"
"github.com/miniflux/miniflux/version"
)

View File

@ -8,6 +8,7 @@ import (
"context"
"os"
"os/signal"
"runtime"
"syscall"
"time"
@ -27,6 +28,16 @@ func Run(cfg *config.Config, store *storage.Storage) {
signal.Notify(stop, os.Interrupt)
signal.Notify(stop, syscall.SIGTERM)
go func() {
for {
var m runtime.MemStats
runtime.ReadMemStats(&m)
logger.Debug("Alloc=%vK, TotalAlloc=%vK, Sys=%vK, NumGC=%v, GoRoutines=%d, NumCPU=%d",
m.Alloc/1024, m.TotalAlloc/1024, m.Sys/1024, m.NumGC, runtime.NumGoroutine(), runtime.NumCPU())
time.Sleep(30 * time.Second)
}
}()
translator := locale.Load()
feedHandler := feed.NewFeedHandler(store, translator)
pool := scheduler.NewWorkerPool(feedHandler, cfg.WorkerPoolSize())