func (p *dockerProvisioner) SetUnitStatus(unit provision.Unit, status provision.Status) error { container, err := p.getContainer(unit.Name) if err != nil { return err } if unit.AppName != "" && container.AppName != unit.AppName { return errors.New("wrong app name") } return container.setStatus(p, status.String()) }
func (p *dockerProvisioner) SetUnitStatus(unit provision.Unit, status provision.Status) error { container, err := p.GetContainer(unit.ID) if err == provision.ErrUnitNotFound && unit.Name != "" { container, err = p.GetContainerByName(unit.Name) } if err != nil { return err } if unit.AppName != "" && container.AppName != unit.AppName { return errors.New("wrong app name") } err = container.SetStatus(p, status.String(), true) if err != nil { return err } return p.checkContainer(container) }
func (c *Container) SetStatus(p DockerProvisioner, status provision.Status, updateDB bool) error { c.Status = status.String() c.LastStatusUpdate = time.Now().In(time.UTC) updateData := bson.M{ "status": c.Status, "laststatusupdate": c.LastStatusUpdate, } if c.Status == provision.StatusStarted.String() || c.Status == provision.StatusStarting.String() { c.LastSuccessStatusUpdate = c.LastStatusUpdate updateData["lastsuccessstatusupdate"] = c.LastSuccessStatusUpdate } if !updateDB { return nil } coll := p.Collection() defer coll.Close() return coll.Update(bson.M{"id": c.ID, "status": bson.M{"$ne": provision.StatusBuilding.String()}}, bson.M{"$set": updateData}) }
func (p *dockerProvisioner) SetUnitStatus(unit provision.Unit, status provision.Status) error { cont, err := p.GetContainer(unit.ID) if _, ok := err.(*provision.UnitNotFoundError); ok && unit.Name != "" { cont, err = p.GetContainerByName(unit.Name) } if err != nil { return err } if cont.Status == provision.StatusBuilding.String() { return nil } if unit.AppName != "" && cont.AppName != unit.AppName { return stderr.New("wrong app name") } err = cont.SetStatus(p, status.String(), true) if err != nil { return err } return p.checkContainer(cont) }