Dan Anglin
ee910722cb
Add support for taking on demand backups of Code Flow. Resolves flow/services#7
38 lines
764 B
Go
38 lines
764 B
Go
package actions
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"flow/services/internal"
|
|
"flow/services/internal/config"
|
|
|
|
"github.com/magefile/mage/sh"
|
|
)
|
|
|
|
func Shutdown(environment string) error {
|
|
cfg, err := config.NewConfig(environment)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to load the configuration; %w", err)
|
|
}
|
|
|
|
if err := shutdown(cfg.Docker.Host, environment); err != nil {
|
|
return fmt.Errorf("unable to shutdown the %q environment; %w", environment, err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func shutdown(dockerHost, environment string) error {
|
|
os.Setenv("DOCKER_HOST", dockerHost)
|
|
|
|
command := []string{
|
|
"docker",
|
|
"compose",
|
|
"--project-directory",
|
|
fmt.Sprintf("%s/%s/compose", internal.RootBuildDir, environment),
|
|
"down",
|
|
}
|
|
|
|
return sh.RunV(command[0], command[1:]...)
|
|
}
|