fix: more performant ps'in
This commit is contained in:
parent
2ba1ec3df0
commit
5cd4317580
|
@ -8,11 +8,13 @@ import (
|
||||||
"coopcloud.tech/abra/cli/internal"
|
"coopcloud.tech/abra/cli/internal"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
"coopcloud.tech/abra/pkg/client"
|
"coopcloud.tech/abra/pkg/client"
|
||||||
|
"coopcloud.tech/abra/pkg/config"
|
||||||
stack "coopcloud.tech/abra/pkg/upstream/stack"
|
stack "coopcloud.tech/abra/pkg/upstream/stack"
|
||||||
"github.com/buger/goterm"
|
"github.com/buger/goterm"
|
||||||
"github.com/docker/cli/cli/command/formatter"
|
"github.com/docker/cli/cli/command/formatter"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
dockerClient "github.com/docker/docker/client"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
@ -27,23 +29,6 @@ var appPsCommand = &cli.Command{
|
||||||
},
|
},
|
||||||
BashComplete: autocomplete.AppNameComplete,
|
BashComplete: autocomplete.AppNameComplete,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
if !internal.Watch {
|
|
||||||
showPSOutput(c)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
goterm.Clear()
|
|
||||||
for {
|
|
||||||
goterm.MoveCursor(1, 1)
|
|
||||||
showPSOutput(c)
|
|
||||||
goterm.Flush()
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// showPSOutput renders ps output.
|
|
||||||
func showPSOutput(c *cli.Context) {
|
|
||||||
app := internal.ValidateApp(c)
|
app := internal.ValidateApp(c)
|
||||||
|
|
||||||
cl, err := client.New(app.Server)
|
cl, err := client.New(app.Server)
|
||||||
|
@ -60,6 +45,23 @@ func showPSOutput(c *cli.Context) {
|
||||||
logrus.Fatalf("%s is not deployed?", app.Name)
|
logrus.Fatalf("%s is not deployed?", app.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !internal.Watch {
|
||||||
|
showPSOutput(c, app, cl)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
goterm.Clear()
|
||||||
|
for {
|
||||||
|
goterm.MoveCursor(1, 1)
|
||||||
|
showPSOutput(c, app, cl)
|
||||||
|
goterm.Flush()
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// showPSOutput renders ps output.
|
||||||
|
func showPSOutput(c *cli.Context, app config.App, cl *dockerClient.Client) {
|
||||||
filters := filters.NewArgs()
|
filters := filters.NewArgs()
|
||||||
filters.Add("name", app.StackName())
|
filters.Add("name", app.StackName())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue