summaryrefslogtreecommitdiff
path: root/cmd/rr
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-10 18:44:04 +0300
committerWolfy-J <[email protected]>2018-06-10 18:44:04 +0300
commit41ae7e1f8c57075ba19c41f4c5c07da1807f8e1b (patch)
treeba705bbcb83c648ffcdf337864b96b4205fe8d32 /cmd/rr
parentba99a17a3a7bb88d44fdc6e65001ef0b0dcd6833 (diff)
better workers list
Diffstat (limited to 'cmd/rr')
-rw-r--r--cmd/rr/http/workers.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/cmd/rr/http/workers.go b/cmd/rr/http/workers.go
index 62730e25..6083f10c 100644
--- a/cmd/rr/http/workers.go
+++ b/cmd/rr/http/workers.go
@@ -31,7 +31,8 @@ import (
"os"
"strconv"
"time"
- "github.com/fatih/color"
+ "github.com/dustin/go-humanize"
+ "github.com/spiral/roadrunner/cmd/rr/utils"
)
func init() {
@@ -60,11 +61,11 @@ func workersHandler(cmd *cobra.Command, args []string) error {
}
tw := tablewriter.NewWriter(os.Stdout)
- tw.SetHeader([]string{"PID", "Status", "Handled Jobs", "Alive"})
+ tw.SetHeader([]string{"PID", "Status", "Execs", "Created"})
for _, w := range r.Workers {
tw.Append([]string{
- color.YellowString(strconv.Itoa(w.Pid)),
+ strconv.Itoa(w.Pid),
renderStatus(w.Status),
renderJobs(w.NumJobs),
renderAlive(time.Unix(0, w.Created)),
@@ -77,13 +78,26 @@ func workersHandler(cmd *cobra.Command, args []string) error {
}
func renderStatus(status string) string {
+ switch status {
+ case "inactive":
+ return utils.Sprintf("<yellow>inactive</reset>")
+ case "ready":
+ return utils.Sprintf("<cyan>ready</reset>")
+ case "working":
+ return utils.Sprintf("<green>working</reset>")
+ case "stopped":
+ return utils.Sprintf("<red>stopped</reset>")
+ case "errored":
+ return utils.Sprintf("<red>errored</reset>")
+ }
+
return status
}
func renderJobs(number uint64) string {
- return strconv.Itoa(int(number))
+ return humanize.Comma(int64(number))
}
func renderAlive(t time.Time) string {
- return time.Now().Sub(t).String()
+ return humanize.RelTime(t, time.Now(), "ago", "")
}