Beispiel #1
0
func (self *ContainerManager) Manage(host string, container *config.Container) error {
	if config.NotIn(self.UsedContainerNames[host], container.Name()) {
		self.UsedContainerNames[host] = append(self.UsedContainerNames[host], container.Name())
	}
	err := self.Launch(host, container)
	if err != nil {
		return err
	}
	return self.StopExtra(host, container)
}
Beispiel #2
0
func (self *ContainerManager) StopUnused() error {
	for host, containers := range self.RunningContainers {
		for _, container := range containers {
			if config.NotIn(self.UsedContainerNames[host], container.LabelName()) {
				vClient := self.Clients[host]
				err := vClient.Stop(container.ContainerId)
				if err != nil {
					return err
				}
				fmt.Println("stopped " + container.String())
			}
		}
	}
	return nil
}