fix: mysql 端口修改时,重启相关容器

pull/189/head
ssongliu 2 years ago committed by ssongliu
parent 0ff7c418bd
commit 5c84277f12

@ -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) {

Loading…
Cancel
Save