Esempio n. 1
0
File: git.go Progetto: nihao/tsuru
func Git(app provision.App, 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 := repository.CloneOrPull(app)
	if err != nil {
		msg := fmt.Sprintf("Got error while clonning/pulling repository: %s -- \n%s", err.Error(), string(out))
		log.Write(w, []byte(msg))
		return errors.New(msg)
	}
	log.Write(w, out)
	log.Write(w, []byte("\n ---> Installing dependencies\n"))
	if err := app.InstallDeps(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"))
}
Esempio n. 2
0
func CloneRepositoryHandler(w http.ResponseWriter, r *http.Request) error {
	w.Header().Set("Content-Type", "text")
	instance := app.App{Name: r.URL.Query().Get(":name")}
	err := instance.Get()
	logWriter := LogWriter{&instance, w}
	if err != nil {
		return &errors.Http{Code: http.StatusNotFound, Message: fmt.Sprintf("App %s not found.", instance.Name)}
	}
	err = write(&logWriter, []byte("\n ---> Tsuru receiving push\n"))
	if err != nil {
		return err
	}
	err = write(&logWriter, []byte("\n ---> Replicating the application repository across units\n"))
	if err != nil {
		return err
	}
	out, err := repository.CloneOrPull(&instance) // should iterate over the machines
	if err != nil {
		return &errors.Http{Code: http.StatusInternalServerError, Message: string(out)}
	}
	err = write(&logWriter, out)
	if err != nil {
		return err
	}
	err = write(&logWriter, []byte("\n ---> Installing dependencies\n"))
	if err != nil {
		return err
	}
	err = instance.InstallDeps(&logWriter)
	if err != nil {
		return err
	}
	err = instance.Restart(&logWriter)
	if err != nil {
		return err
	}
	return write(&logWriter, []byte("\n ---> Deploy done!\n\n"))
}