services/internal/actions/stop.go
Dan Anglin ee910722cb
feat: add backup support for Code Flow
Add support for taking on demand backups of Code Flow.
Resolves flow/services#7
2023-12-17 08:51:11 +00:00

38 lines
765 B
Go

package actions
import (
"flow/services/internal"
"flow/services/internal/config"
"fmt"
"os"
"github.com/magefile/mage/sh"
)
func Stop(environment, service string) error {
cfg, err := config.NewConfig(environment)
if err != nil {
return fmt.Errorf("unable to load the configuration; %w", err)
}
if err := stop(cfg.Docker.Host, environment, service); err != nil {
return fmt.Errorf("unable to stop %q; %w", service, err)
}
return nil
}
func stop(dockerHost, environment, service string) error {
os.Setenv("DOCKER_HOST", dockerHost)
command := []string{
"docker",
"compose",
"--project-directory",
fmt.Sprintf("%s/%s/compose", internal.RootBuildDir, environment),
"stop",
service,
}
return sh.RunV(command[0], command[1:]...)
}