예제 #1
0
파일: stable.go 프로젝트: mkindahl/gomysqld
// Open is used to open an existing stable at the given path. If
// successful, a new stable is returned.
func OpenStable(path string) (*Stable, error) {
	stable, err := newStable(path)
	log.Infof("Opening stable in %q", stable.Root)
	if err != nil {
		return nil, err
	}
	if err := stable.ReadConfig(); err != nil {
		return nil, err
	}
	return stable, nil
}
예제 #2
0
파일: dist.go 프로젝트: mkindahl/gomysqld
// unpackFrom will ensure that the distribution is unpacked and
// installed in the distribution tree under the root directory for
// distributions. If this function finishes successfully, nil is
// returned, otherwise, an error is returned.
func (dt *Dist) unpackDist(root, path string) error {
	log.Infof("Unpacking distribution %s into %s\n", path, root)
	switch pathType(path) {
	case TGZ_PATH:
		return dt.unpackTar(root, path)
	case ZIP_PATH:
		return dt.unpackZip(root, path)
	case DIR_PATH:
		dt.Name = filepath.Base(path)
		dt.Root = filepath.Join(root, dt.Name)
		os.Symlink(path, dt.Name)
		return nil
	default:
		return ErrInvalidDist
	}
}
예제 #3
0
파일: stable.go 프로젝트: mkindahl/gomysqld
// CreateStable creates a new stable where distributions and servers
// can be created.
func CreateStable(path string) (*Stable, error) {
	stable, err := newStable(path)
	if err != nil {
		return nil, err
	}

	log.Infof("Creating stable in %q", stable.Root)

	if err := stable.setup(); err != nil {
		return nil, err
	}

	if err := stable.WriteConfig(); err != nil {
		return nil, err
	}

	return stable, nil
}
예제 #4
0
파일: stable.go 프로젝트: mkindahl/gomysqld
func (stable *Stable) Destroy() error {
	log.Infof("Destroying stable in %q", stable.Root)
	return stable.teardown()
}
예제 #5
0
파일: stable.go 프로젝트: mkindahl/gomysqld
func (stable *Stable) teardown() error {
	log.Infof("Destroying stable in %q\n", stable.Root)
	return os.RemoveAll(stable.Root)
}