From cb3e7a6b4ec294e7c44c0752f88ffea2297d58b9 Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Sun, 10 Jun 2018 18:53:28 +0300 Subject: nicer command --- cmd/rr/.rr.yaml | 2 +- cmd/rr/http/workers.go | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/rr/.rr.yaml b/cmd/rr/.rr.yaml index 34475da7..bf4c699b 100644 --- a/cmd/rr/.rr.yaml +++ b/cmd/rr/.rr.yaml @@ -33,7 +33,7 @@ http: # worker pool configuration. pool: # number of workers to be serving. - numWorkers: 2 + numWorkers: 16 # maximum jobs per worker, 0 - unlimited. maxJobs: 0 diff --git a/cmd/rr/http/workers.go b/cmd/rr/http/workers.go index 6083f10c..9ad20be7 100644 --- a/cmd/rr/http/workers.go +++ b/cmd/rr/http/workers.go @@ -33,6 +33,7 @@ import ( "time" "github.com/dustin/go-humanize" "github.com/spiral/roadrunner/cmd/rr/utils" + "github.com/shirou/gopsutil/process" ) func init() { @@ -61,13 +62,14 @@ func workersHandler(cmd *cobra.Command, args []string) error { } tw := tablewriter.NewWriter(os.Stdout) - tw.SetHeader([]string{"PID", "Status", "Execs", "Created"}) + tw.SetHeader([]string{"PID", "Status", "Execs", "Memory", "Created"}) for _, w := range r.Workers { tw.Append([]string{ strconv.Itoa(w.Pid), renderStatus(w.Status), renderJobs(w.NumJobs), + renderMemory(w.Pid), renderAlive(time.Unix(0, w.Created)), }) } @@ -101,3 +103,13 @@ func renderJobs(number uint64) string { func renderAlive(t time.Time) string { return humanize.RelTime(t, time.Now(), "ago", "") } + +func renderMemory(pid int) string { + p, _ := process.NewProcess(int32(pid)) + i, err := p.MemoryInfo() + if err != nil { + return err.Error() + } + + return humanize.Bytes(i.RSS) +} -- cgit v1.2.3