From 5c84277f1267eae03aec057e791586f3564bb0a2 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Tue, 7 Mar 2023 20:59:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mysql=20=E7=AB=AF=E5=8F=A3=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=97=B6=EF=BC=8C=E9=87=8D=E5=90=AF=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=AE=B9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app_install.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index ccd6c0f1c..84b05850e 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -273,7 +273,28 @@ func (a AppInstallService) ChangeAppPort(req request.PortUpdate) error { if common.ScanPort(int(req.Port)) { return buserr.WithDetail(constant.ErrPortInUsed, req.Port, nil) } - return updateInstallInfoInDB(req.Key, "", "port", true, strconv.FormatInt(req.Port, 10)) + + appInstall, err := appInstallRepo.LoadBaseInfo(req.Key, req.Name) + if err != nil { + return nil + } + + if err := updateInstallInfoInDB(req.Key, "", "port", true, strconv.FormatInt(req.Port, 10)); err != nil { + return nil + } + + appRess, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(appInstall.ID)) + for _, appRes := range appRess { + appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(appRes.AppInstallId)) + if err != nil { + return err + } + if _, err := compose.Restart(fmt.Sprintf("%s/%s/%s/docker-compose.yml", constant.AppInstallDir, appInstall.App.Key, appInstall.Name)); err != nil { + global.LOG.Errorf("docker-compose restart %s[%s] failed, err: %v", appInstall.App.Key, appInstall.Name, err) + } + } + + return nil } func (a AppInstallService) DeleteCheck(installId uint) ([]dto.AppResource, error) {