func BundleInstall(args ...string) { if cfg == nil { config.LoadConfigs() for _, process := range config.List() { SetProcess(process) SetConfig(config.Process(process)) BundleInstall(args...) } } else if cfg.UseBundler { runExec("bundle", "install", "--path", ".gems") } }
func appHandler(w http.ResponseWriter, r *http.Request, app string) { path := fmt.Sprintf("%s/%s", command.Root(), app) os.Chdir(path) config.LoadConfigs() b, err := json.Marshal(config.Processes()) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } renderTemplateString(w, string(b)) }
func postUpdate() { if cfg == nil { config.LoadConfigs() for _, process := range config.List() { SetProcess(process) SetConfig(config.Process(process)) postInstall() } } else if cfg.PostUpdate != "" { cmd := exec.Command(cfg.PostUpdate) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Run() } }
// Build will create the container if nessary func Build(args ...string) { wd, _ := os.Getwd() logger.Log(fmt.Sprintf("In %s to build.", wd)) if cfg != nil { logger.Log(fmt.Sprintf("Building...%s\n", cfg.App)) cmd := exec.Command("docker", "build", "-t", cfg.Container, cfg.BuildFile) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Stdin = os.Stdin cmd.Run() } else { config.LoadConfigs() for _, process := range config.List() { SetProcess(process) SetConfig(config.Process(process)) Build(args...) } } }
func commandHandler(w http.ResponseWriter, r *http.Request) { logger.Log(fmt.Sprintln("Command Handler")) base := r.URL.Path[len("/commands/"):] opts := strings.Split(base, "/") logger.Log(fmt.Sprintf("Commands: %v", opts)) site := opts[0] process := opts[1] cmd := opts[2] path := fmt.Sprintf("%s/%s", command.Root(), site) os.Chdir(path) command.MkDirs() config.LoadConfigs() old := os.Stdout re, wr, _ := os.Pipe() os.Stdout = wr command.ParseCommand([]string{process, cmd}) outC := make(chan string) go func() { var buf bytes.Buffer io.Copy(&buf, re) outC <- buf.String() }() wr.Close() os.Stdout = old out := <-outC clean := strings.Replace(out, "\n", "</br>", -1) o := map[string]string{"status": "ok", "output": clean} b, err := json.Marshal(o) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } renderTemplateString(w, string(b)) }