コード例 #1
0
ファイル: git.go プロジェクト: rochacon/tsuru
func Git(provisioner provision.Provisioner, app provision.App, objID string, w io.Writer) error {
	log.Write(w, []byte("\n ---> tsuru receiving push\n"))
	log.Write(w, []byte("\n ---> Replicating the application repository across units\n"))
	out, err := clone(provisioner, app)
	if err != nil {
		out, err = fetch(provisioner, app)
	}
	if err != nil {
		msg := fmt.Sprintf("Got error while cloning/fetching repository: %s -- \n%s", err, string(out))
		log.Write(w, []byte(msg))
		return errors.New(msg)
	}
	out, err = checkout(provisioner, app, objID)
	if err != nil {
		msg := fmt.Sprintf("Failed to checkout Git repository: %s -- \n%s", err, string(out))
		log.Write(w, []byte(msg))
		return errors.New(msg)
	}
	log.Write(w, []byte("\n ---> Installing dependencies\n"))
	if err := provisioner.InstallDeps(app, w); err != nil {
		log.Write(w, []byte(err.Error()))
		return err
	}
	log.Write(w, []byte("\n ---> Restarting application\n"))
	if err := app.Restart(w); err != nil {
		log.Write(w, []byte(err.Error()))
		return err
	}
	return log.Write(w, []byte("\n ---> Deploy done!\n\n"))
}
コード例 #2
0
ファイル: provisioner.go プロジェクト: philiptzou/tsuru
func injectEnvsAndRestart(a provision.App) {
	time.Sleep(5e9)
	err := a.SerializeEnvVars()
	if err != nil {
		log.Errorf("Failed to serialize env vars: %s.", err)
	}
	var buf bytes.Buffer
	w := app.LogWriter{App: a, Writer: &buf}
	err = a.Restart(&w)
	if err != nil {
		log.Errorf("Failed to restart app %q (%s): %s.", a.GetName(), err, buf.String())
	}
}