Esempio n. 1
0
func (c *Container) Start() {
	c.init()

	fmt.Println("Starting", c.Name, "...")

	if c.IsRunning() {
		fmt.Println("Application", c.Name, "already running", "("+c.Ip+":"+c.GetFirstPort()+")")
		return
	}

	startResult := docker.Start(c.Name, c.Image, c.Links, c.Ports, c.Volumes)
	c.Id = strings.TrimSpace(startResult)

	time.Sleep(3 * time.Second)
	c.RetrieveIp()
	c.Running = true

	fmt.Println("Application", c.Name, "started", "("+c.Ip+":"+c.GetFirstPort()+")")
}
Esempio n. 2
0
/**
 * Starts a container as a server
 */
func (c *Container) Start(rebuild bool) {
	// Check if the container is already running
	if !rebuild {
		if c.IsRunning() {
			util.PrintGreen("Application", c.Name, "is already running", "("+c.Ip+":"+c.GetFirstPort()+")")
			return
		}

		cleanChan := make(chan bool, 1)
		go c.Clean(cleanChan)
		<-cleanChan
	}

	util.PrintGreen("Starting", c.Name, "...")

	startResult := docker.Start(c.Name, c.Image, c.Links, c.Ports, c.Volumes, c.Environments)
	c.Id = strings.TrimSpace(startResult)

	time.Sleep(3 * time.Second)
	c.RetrieveIp()
	c.Running = true

	util.PrintGreen("Application", c.Name, "started", "("+c.Ip+":"+c.GetFirstPort()+")")
}