func InstancesList(rw http.ResponseWriter, r *http.Request) *httperr.Error { instances, err := provider.InstanceList() if err != nil { return httperr.Server(err) } return RenderJson(rw, instances) }
func ListOneoffProcesses(app string) (Processes, error) { instances, err := provider.InstanceList() if err != nil { return nil, err } procs := Processes{} for _, instance := range instances { d, err := instance.DockerClient() if err != nil { return nil, err } pss, err := d.ListContainers(docker.ListContainersOptions{ Filters: map[string][]string{ "label": []string{ "com.convox.rack.type=oneoff", fmt.Sprintf("com.convox.rack.app=%s", app), }, }, }) if err != nil { return nil, err } for _, ps := range pss { c, err := d.InspectContainer(ps.ID) if err != nil { return nil, err } procs = append(procs, &Process{ Id: ps.ID[0:12], Command: ps.Command, Host: instance.Ip(), Name: ps.Labels["com.convox.rack.process"], Release: ps.Labels["com.convox.rack.release"], Size: c.HostConfig.Memory, Started: time.Unix(ps.Created, 0), containerId: ps.ID, taskArn: "", // empty taskArn indicated Docker container, not ECS task }) } } return procs, nil }