1Panel/backend/utils/compose/compose.go

40 lines
909 B
Go
Raw Normal View History

package compose
import "os/exec"
func Up(filePath string) (string, error) {
cmd := exec.Command("docker-compose", "-f", filePath, "up", "-d")
stdout, err := cmd.CombinedOutput()
if err != nil {
return string(stdout), err
}
return string(stdout), nil
}
func Down(filePath string) (string, error) {
cmd := exec.Command("docker-compose", "-f", filePath, "down")
stdout, err := cmd.CombinedOutput()
if err != nil {
return "", err
}
return string(stdout), nil
}
func Restart(filePath string) (string, error) {
cmd := exec.Command("docker-compose", "-f", filePath, "restart")
stdout, err := cmd.CombinedOutput()
if err != nil {
return "", err
}
return string(stdout), nil
}
2022-09-26 22:54:38 +08:00
func Rmf(filePath string) (string, error) {
cmd := exec.Command("docker-compose", "-f", filePath, "rm", "-f")
stdout, err := cmd.CombinedOutput()
if err != nil {
return "", err
}
return string(stdout), nil
}