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