Пример #1
0
func (p *Postgres) Start(pgdata string, port int) error {
	bin := p.binPath("pg_ctl")
	args := []string{"start", "-D", pgdata}
	cmd := exec.Command(bin, args...)

	cmd.Env = []string{
		fmt.Sprintf("PGPORT=%d", port),
	}

	return util.RunCommandWithDebugLog(cmd)
}
Пример #2
0
func configure(workdir string, installPath string, options []string, debug bool) error {
	cmd := configureCommand(workdir, installPath, options, debug)

	log.WithField("configure options", cmd.Args[1:]).Info("configure")

	err := util.RunCommandWithDebugLog(cmd)
	if err != nil {
		return err
	}
	return nil
}
Пример #3
0
func makeInstall(parallel bool, workdir string) error {
	args := []string{"install"}
	if parallel {
		args = append(args, "-j")
		args = append(args, fmt.Sprint(runtime.NumCPU()))
	}
	cmd := exec.Command("make", args...)
	cmd.Dir = workdir

	log.WithField("options", cmd.Args[2:]).Info("make install")
	if err := util.RunCommandWithDebugLog(cmd); err != nil {
		return fmt.Errorf("failed to make install: %s", err)
	}
	return nil
}
Пример #4
0
func Clone(path string, url string, options []string) error {
	if exists(path) {
		return errors.New("local reporitory already exists")
	}

	args := []string{"clone"}
	for _, o := range options {
		args = append(args, o)
	}
	args = append(args, url)
	args = append(args, path)

	cmd := exec.Command("git", args...)
	return util.RunCommandWithDebugLog(cmd)
}
Пример #5
0
func (p *Postgres) Stop(pgdata string) error {
	bin := p.binPath("pg_ctl")
	args := []string{"stop", "-D", pgdata}
	cmd := exec.Command(bin, args...)
	return util.RunCommandWithDebugLog(cmd)
}
Пример #6
0
func (p *Postgres) Initdb(args []string) error {
	bin := p.binPath("initdb")
	cmd := exec.Command(bin, args...)
	return util.RunCommandWithDebugLog(cmd)
}