forked from coop-cloud/abra
WIP: half-baked errors implementation
This commit is contained in:
parent
4089949a3f
commit
696172ad48
|
@ -1,7 +1,15 @@
|
||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"coopcloud.tech/abra/cli/internal"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
|
"coopcloud.tech/abra/pkg/client"
|
||||||
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,9 +27,52 @@ by "abra app logs <app>".
|
||||||
Flags: []cli.Flag{},
|
Flags: []cli.Flag{},
|
||||||
BashComplete: autocomplete.AppNameComplete,
|
BashComplete: autocomplete.AppNameComplete,
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
// TODO: entrypoint error
|
app := internal.ValidateApp(c)
|
||||||
// TODO: ps --no-trunc errors
|
|
||||||
// TODO: failing healthcheck
|
cl, err := client.New(app.Server)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
filters := filters.NewArgs()
|
||||||
|
filters.Add("name", app.StackName())
|
||||||
|
|
||||||
|
containers, err := cl.ContainerList(c.Context, types.ContainerListOptions{Filters: filters})
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// tableCol := []string{"status", "error", "healthcheck", "healthcheck logs"}
|
||||||
|
// table := abraFormatter.CreateTable(tableCol)
|
||||||
|
|
||||||
|
for _, container := range containers {
|
||||||
|
fmt.Println("service: ", strings.Join(container.Names, ""))
|
||||||
|
|
||||||
|
containerState, err := cl.ContainerInspect(c.Context, container.ID)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("restarted no. times: ", containerState.RestartCount)
|
||||||
|
fmt.Println("status: ", containerState.State.Status)
|
||||||
|
fmt.Println("oom killed: ", containerState.State.OOMKilled)
|
||||||
|
|
||||||
|
if containerState.State.Health != nil {
|
||||||
|
fmt.Println("healthcheck status: ", containerState.State.Health.Status)
|
||||||
|
fmt.Println("failed no. times: ", containerState.State.Health.FailingStreak)
|
||||||
|
for _, log := range containerState.State.Health.Log {
|
||||||
|
fmt.Println("output: ", log.Output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("---")
|
||||||
|
|
||||||
|
// table.Append([]string{containerState.State.Status, containerState.State.Error, healthCheckState, healthCheckLogs})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// table.Render()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue