Refactor process.go for platform specific
Signed-off-by: John Howard <jhoward@microsoft.com> Move process sorter to new file Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Sort containers by id This will not be the most accurate sorting but atleast the list will be consistent inbetween calls. Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Allow runtime to be configurable via daemon start This allows people to pass an alternate name or location to the runtime binary to start containers. Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Fix state output for containers Return the proper state/status for a container by checking if the pid is still alive. Also fix the cleanup handling in the shim to make sure containers are not left behind. Signed-off-by: Michael Crosby <crosbymichael@gmail.com> Properly wait for container start Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
0ad7654f80
commit
b044ff0f29
19 changed files with 323 additions and 206 deletions
|
@ -92,6 +92,7 @@ func listContainers(context *cli.Context) {
|
|||
}
|
||||
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
|
||||
fmt.Fprint(w, "ID\tPATH\tSTATUS\tPROCESSES\n")
|
||||
sortContainers(resp.Containers)
|
||||
for _, c := range resp.Containers {
|
||||
procs := []string{}
|
||||
for _, p := range c.Processes {
|
||||
|
|
27
ctr/sort.go
Normal file
27
ctr/sort.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/docker/containerd/api/grpc/types"
|
||||
)
|
||||
|
||||
func sortContainers(c []*types.Container) {
|
||||
sort.Sort(&containerSorter{c})
|
||||
}
|
||||
|
||||
type containerSorter struct {
|
||||
c []*types.Container
|
||||
}
|
||||
|
||||
func (s *containerSorter) Len() int {
|
||||
return len(s.c)
|
||||
}
|
||||
|
||||
func (s *containerSorter) Swap(i, j int) {
|
||||
s.c[i], s.c[j] = s.c[j], s.c[i]
|
||||
}
|
||||
|
||||
func (s *containerSorter) Less(i, j int) bool {
|
||||
return s.c[i].Id < s.c[j].Id
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue