Esempio n. 1
0
func ProcessRunAttached(ws *websocket.Conn) {
	defer ws.Close()

	log := processesLogger("run.attached").Start()

	vars := mux.Vars(ws.Request())
	app := vars["app"]
	process := vars["process"]
	command := ws.Request().Header.Get("Command")

	ps, err := models.GetProcess(app, process)

	if err != nil {
		helpers.Error(log, err)
		ws.Write([]byte(fmt.Sprintf("error: %s\n", err)))
		return
	}

	log.Success("step=upgrade app=%q", ps.App)

	defer ws.Close()

	err = ps.RunAttached(command, ws)

	if err != nil {
		helpers.Error(log, err)
		ws.Write([]byte(fmt.Sprintf("error: %s\n", err)))
		return
	}

	log.Success("step=ended app=%q", ps.App)
}
Esempio n. 2
0
func ProcessRun(rw http.ResponseWriter, r *http.Request) {
	log := processesLogger("run").Start()

	vars := mux.Vars(r)
	app := vars["app"]
	process := vars["process"]
	command := GetForm(r, "command")

	_, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		RenderNotFound(rw, fmt.Sprintf("no such app: %s", app))
		return
	}

	ps, err := models.GetProcess(app, process)

	if err != nil {
		helpers.Error(log, err)
		RenderError(rw, err)
		return
	}

	if ps == nil {
		RenderNotFound(rw, fmt.Sprintf("no such process: %s", process))
		return
	}

	err = ps.Run(models.ProcessRunOptions{
		Command: command,
		Process: process,
	})

	if err != nil {
		helpers.Error(log, err)
		RenderError(rw, err)
		return
	}

	RenderText(rw, "ok")
}
Esempio n. 3
0
func ProcessShow(rw http.ResponseWriter, r *http.Request) {
	log := processesLogger("show").Start()

	vars := mux.Vars(r)
	app := vars["app"]
	process := vars["process"]

	_, err := models.GetApp(app)

	if awsError(err) == "ValidationError" {
		RenderNotFound(rw, fmt.Sprintf("no such app: %s", app))
		return
	}

	p, err := models.GetProcess(app, process)

	if err != nil {
		helpers.Error(log, err)
		RenderError(rw, err)
		return
	}

	RenderTemplate(rw, "process", p)
}