func BoxDeploy(name string, repoUrl string, pathspec string, stream *hub.Stream) (err error) { defer func() { stream.Close(err) }() box, err := farmer.FindBoxByName(name) if err != nil { return errors.New("Cannot find box '" + name + "'") } if box.State == farmer.StagingState { return errors.New("Box '" + name + "' is in Staging progress!") } box.OutputStream = stream box.ErrorStream = stream if repoUrl == "" { repoUrl = box.Production.RepoUrl } if pathspec == "" { pathspec = box.Production.Pathspec } if err = box.Release(repoUrl, pathspec); err != nil { return } dispatcher.Trigger("new_release", box) return nil }
func BoxDeploy(name string, pathspec string, stream *hub.Stream) (err error) { defer func() { if err != nil { stream.Write([]byte(err.Error())) } stream.Write([]byte("kthxbai")) stream.Close() }() box, err := farmer.FindBoxByName(name) if err != nil { return err } box.OutputStream = stream box.ErrorStream = stream box.Pathspec = pathspec if err := box.Deploy(); err != nil { return err } return db.DB.Save(box).Error }
func BoxCreate(name string, repoUrl string, pathspec string, stream *hub.Stream) (err error) { defer func() { if err != nil { stream.Write([]byte(err.Error())) } stream.Write([]byte("kthxbai")) stream.Close() }() box := farmer.Box{ Name: name, OutputStream: stream, ErrorStream: stream, RepoUrl: repoUrl, Pathspec: pathspec, CodeDirectory: os.Getenv("FARMER_BOX_DATA_LOCATION") + "/" + name, CgroupParent: "level1", } if err := db.DB.Save(&box).Error; err != nil { return err } if err := box.Create(); err != nil { os.RemoveAll(box.CodeDirectory) db.DB.Delete(&box) return err } return db.DB.Save(&box).Error }
func BoxCreate(name string, repoUrl string, pathspec string, stream *hub.Stream) (err error) { defer func() { stream.Close(err) }() box := farmer.Box{ Name: name, Directory: os.Getenv("FARMER_BOX_DATA_LOCATION") + "/" + name, OutputStream: stream, ErrorStream: stream, UpdateTime: time.Now().Local().Format(farmer.TimeFormat), } box.KeepReleases, _ = strconv.Atoi(os.Getenv("FARMER_BOX_KEEP_RELEASES")) if err = box.Setup(); err != nil { return } if err = box.Release(repoUrl, pathspec); err != nil { return } return }
func BoxDeploy(name string, repoUrl string, pathspec string, stream *hub.Stream) (err error) { defer func() { if err != nil { stream.Write([]byte(err.Error())) } stream.Write([]byte("kthxbai")) stream.Close() }() currentBox, err := farmer.FindBoxByName(name) if err != nil { return err } if pathspec != "" { currentBox.Pathspec = pathspec } if repoUrl != "" { currentBox.RepoUrl = repoUrl } currentBox.OutputStream = stream currentBox.ErrorStream = stream updatedBox, err := currentBox.Revision() if err != nil { updatedBox.DestroyRevision() return err } if err := reverse_proxy.ConfigureDomains(updatedBox); err != nil { updatedBox.DestroyRevision() reverse_proxy.ConfigureDomains(currentBox) return err } reverse_proxy.Restart() currentBox.DestroyRevision() return db.DB.Save(updatedBox).Error }