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

36 lines
923 B
Go
Raw Normal View History

package compose
import (
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
)
func Up(filePath string) (string, error) {
2023-05-18 16:48:19 +08:00
stdout, err := cmd.Execf("docker compose -f %s up -d", filePath)
return stdout, err
}
func Down(filePath string) (string, error) {
2023-05-18 16:48:19 +08:00
stdout, err := cmd.Execf("docker compose -f %s down --remove-orphans", filePath)
return stdout, err
2022-12-06 15:59:25 +08:00
}
2023-03-01 11:51:49 +08:00
func Start(filePath string) (string, error) {
2023-05-18 16:48:19 +08:00
stdout, err := cmd.Execf("docker compose -f %s start", filePath)
2023-03-01 11:51:49 +08:00
return stdout, err
}
2022-12-06 15:59:25 +08:00
func Stop(filePath string) (string, error) {
2023-05-18 16:48:19 +08:00
stdout, err := cmd.Execf("docker compose -f %s stop", filePath)
return stdout, err
}
func Restart(filePath string) (string, error) {
2023-05-18 16:48:19 +08:00
stdout, err := cmd.Execf("docker compose -f %s restart", filePath)
return stdout, err
}
2022-09-26 22:54:38 +08:00
2022-12-06 15:05:13 +08:00
func Operate(filePath, operation string) (string, error) {
2023-05-18 16:48:19 +08:00
stdout, err := cmd.Execf("docker compose -f %s %s", filePath, operation)
return stdout, err
2022-09-26 22:54:38 +08:00
}