mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-10 19:50:53 +08:00
feat: OpenResty 卸载不删除网站 (#6297)
Refs https://github.com/1Panel-dev/1Panel/issues/5726
This commit is contained in:
parent
bc8a2511d1
commit
c492796cf8
8 changed files with 168 additions and 217 deletions
|
|
@ -618,10 +618,10 @@ func (a *AppInstallService) DeleteCheck(installID uint) ([]dto.AppResource, erro
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
app, err := appRepo.GetFirst(commonRepo.WithByID(appInstall.AppId))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//app, err := appRepo.GetFirst(commonRepo.WithByID(appInstall.AppId))
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
websites, _ := websiteRepo.GetBy(websiteRepo.WithAppInstallId(appInstall.ID))
|
||||
for _, website := range websites {
|
||||
res = append(res, dto.AppResource{
|
||||
|
|
@ -629,25 +629,17 @@ func (a *AppInstallService) DeleteCheck(installID uint) ([]dto.AppResource, erro
|
|||
Name: website.PrimaryDomain,
|
||||
})
|
||||
}
|
||||
if app.Key == constant.AppOpenresty {
|
||||
websites, _ := websiteRepo.GetBy()
|
||||
for _, website := range websites {
|
||||
res = append(res, dto.AppResource{
|
||||
Type: "website",
|
||||
Name: website.PrimaryDomain,
|
||||
})
|
||||
}
|
||||
}
|
||||
if app.Type == constant.Runtime {
|
||||
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(appInstall.ID), commonRepo.WithByFrom(constant.AppResourceLocal))
|
||||
for _, resource := range resources {
|
||||
linkInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(resource.AppInstallId))
|
||||
res = append(res, dto.AppResource{
|
||||
Type: "app",
|
||||
Name: linkInstall.Name,
|
||||
})
|
||||
}
|
||||
}
|
||||
//TODO 根据运行环境情况处理
|
||||
//if app.Type == constant.Runtime {
|
||||
// resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(appInstall.ID), commonRepo.WithByFrom(constant.AppResourceLocal))
|
||||
// for _, resource := range resources {
|
||||
// linkInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(resource.AppInstallId))
|
||||
// res = append(res, dto.AppResource{
|
||||
// Type: "app",
|
||||
// Name: linkInstall.Name,
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"github.com/docker/docker/api/types"
|
||||
|
||||
httpUtil "github.com/1Panel-dev/1Panel/agent/utils/http"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/xpack"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/cmd"
|
||||
|
|
@ -405,25 +404,26 @@ func deleteAppInstall(deleteReq request.AppInstallDelete) error {
|
|||
|
||||
switch install.App.Key {
|
||||
case constant.AppOpenresty:
|
||||
websites, _ := websiteRepo.List()
|
||||
for _, website := range websites {
|
||||
if website.AppInstallID > 0 {
|
||||
websiteAppInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID))
|
||||
if websiteAppInstall.AppId > 0 {
|
||||
websiteApp, _ := appRepo.GetFirst(commonRepo.WithByID(websiteAppInstall.AppId))
|
||||
if websiteApp.Type == constant.RuntimePHP {
|
||||
go func() {
|
||||
_, _ = compose.Down(websiteAppInstall.GetComposePath())
|
||||
_ = op.DeleteDir(websiteAppInstall.GetPath())
|
||||
}()
|
||||
_ = appInstallRepo.Delete(ctx, websiteAppInstall)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = websiteRepo.DeleteAll(ctx)
|
||||
_ = websiteDomainRepo.DeleteAll(ctx)
|
||||
xpack.RemoveTamper("")
|
||||
//TODO 删除 Openresty 不再删除网站
|
||||
//websites, _ := websiteRepo.List()
|
||||
//for _, website := range websites {
|
||||
// if website.AppInstallID > 0 {
|
||||
// websiteAppInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID))
|
||||
// if websiteAppInstall.AppId > 0 {
|
||||
// websiteApp, _ := appRepo.GetFirst(commonRepo.WithByID(websiteAppInstall.AppId))
|
||||
// if websiteApp.Type == constant.RuntimePHP {
|
||||
// go func() {
|
||||
// _, _ = compose.Down(websiteAppInstall.GetComposePath())
|
||||
// _ = op.DeleteDir(websiteAppInstall.GetPath())
|
||||
// }()
|
||||
// _ = appInstallRepo.Delete(ctx, websiteAppInstall)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//_ = websiteRepo.DeleteAll(ctx)
|
||||
//_ = websiteDomainRepo.DeleteAll(ctx)
|
||||
//xpack.RemoveTamper("")
|
||||
case constant.AppMysql, constant.AppMariaDB:
|
||||
_ = mysqlRepo.Delete(ctx, mysqlRepo.WithByMysqlName(install.Name))
|
||||
case constant.AppPostgresql:
|
||||
|
|
|
|||
|
|
@ -433,12 +433,7 @@ func (f *FileService) ReadLogByLine(req request.FileReadByLineReq) (*response.Fi
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nginx, err := getNginxFull(&website)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sitePath := path.Join(nginx.SiteDir, "sites", website.Alias)
|
||||
logFilePath = path.Join(sitePath, "log", req.Name)
|
||||
logFilePath = GetSitePath(website, req.Name)
|
||||
case constant.TypePhp:
|
||||
php, err := runtimeRepo.GetFirst(commonRepo.WithByID(req.ID))
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ func getNginxFull(website *model.Website) (dto.NginxFull, error) {
|
|||
if website != nil {
|
||||
nginxFull.Website = *website
|
||||
var siteNginxConfig dto.NginxConfig
|
||||
nginxFileName := website.Alias + ".conf"
|
||||
siteConfigPath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "conf", "conf.d", nginxFileName)
|
||||
siteConfigPath := GetSitePath(*website, SiteConf)
|
||||
siteNginxConfig.FilePath = siteConfigPath
|
||||
siteNginxContent, err := os.ReadFile(siteConfigPath)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -31,20 +31,18 @@ import (
|
|||
"github.com/1Panel-dev/1Panel/agent/utils/env"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/api/v2/helper"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto/response"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/repo"
|
||||
"github.com/1Panel-dev/1Panel/agent/buserr"
|
||||
"github.com/1Panel-dev/1Panel/agent/cmd/server/nginx_conf"
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/cmd"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/nginx"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/nginx/components"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/nginx/parser"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"gopkg.in/ini.v1"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto/response"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/repo"
|
||||
"github.com/1Panel-dev/1Panel/agent/buserr"
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||
|
|
@ -72,7 +70,7 @@ type IWebsiteService interface {
|
|||
|
||||
GetNginxConfigByScope(req request.NginxScopeReq) (*response.WebsiteNginxConfig, error)
|
||||
UpdateNginxConfigByScope(req request.NginxConfigUpdate) error
|
||||
GetWebsiteNginxConfig(websiteId uint, configType string) (response.FileInfo, error)
|
||||
GetWebsiteNginxConfig(websiteId uint, configType string) (*response.FileInfo, error)
|
||||
UpdateNginxConfigFile(req request.WebsiteNginxUpdate) error
|
||||
GetWebsiteHTTPS(websiteId uint) (response.WebsiteHTTPS, error)
|
||||
OpWebsiteHTTPS(ctx context.Context, req request.WebsiteHTTPSOp) (*response.WebsiteHTTPS, error)
|
||||
|
|
@ -128,13 +126,6 @@ func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []respons
|
|||
websiteDTOs []response.WebsiteRes
|
||||
opts []repo.DBOption
|
||||
)
|
||||
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return 0, nil, nil
|
||||
}
|
||||
return 0, nil, err
|
||||
}
|
||||
opts = append(opts, commonRepo.WithOrderRuleBy(req.OrderBy, req.Order))
|
||||
if req.Name != "" {
|
||||
domains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithDomainLike(req.Name))
|
||||
|
|
@ -179,7 +170,7 @@ func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []respons
|
|||
runtimeType = runtime.Type
|
||||
appInstallID = runtime.ID
|
||||
}
|
||||
sitePath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", web.Alias)
|
||||
sitePath := GetSitePath(web, SiteDir)
|
||||
|
||||
siteDTO := response.WebsiteRes{
|
||||
ID: web.ID,
|
||||
|
|
@ -566,13 +557,10 @@ func (w WebsiteService) GetWebsite(id uint) (response.WebsiteDTO, error) {
|
|||
}
|
||||
res.Website = website
|
||||
|
||||
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
sitePath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", website.Alias)
|
||||
res.ErrorLogPath = path.Join(sitePath, "log", "error.log")
|
||||
res.AccessLogPath = path.Join(sitePath, "log", "access.log")
|
||||
sitePath := GetSitePath(website, SiteDir)
|
||||
|
||||
res.ErrorLogPath = GetSitePath(website, SiteErrorLog)
|
||||
res.AccessLogPath = GetSitePath(website, SiteAccessLog)
|
||||
res.SitePath = sitePath
|
||||
res.SiteDir = website.SiteDir
|
||||
return res, nil
|
||||
|
|
@ -893,33 +881,26 @@ func (w WebsiteService) UpdateNginxConfigByScope(req request.NginxConfigUpdate)
|
|||
return updateNginxConfig(constant.NginxScopeServer, params, &website)
|
||||
}
|
||||
|
||||
func (w WebsiteService) GetWebsiteNginxConfig(websiteId uint, configType string) (response.FileInfo, error) {
|
||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(websiteId))
|
||||
func (w WebsiteService) GetWebsiteNginxConfig(websiteID uint, configType string) (*response.FileInfo, error) {
|
||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(websiteID))
|
||||
if err != nil {
|
||||
return response.FileInfo{}, err
|
||||
return nil, err
|
||||
}
|
||||
configPath := ""
|
||||
switch configType {
|
||||
case constant.AppOpenresty:
|
||||
nginxApp, err := appRepo.GetFirst(appRepo.WithKey(constant.AppOpenresty))
|
||||
if err != nil {
|
||||
return response.FileInfo{}, err
|
||||
}
|
||||
nginxInstall, err := appInstallRepo.GetFirst(appInstallRepo.WithAppId(nginxApp.ID))
|
||||
if err != nil {
|
||||
return response.FileInfo{}, err
|
||||
}
|
||||
configPath = path.Join(nginxInstall.GetPath(), "conf", "conf.d", website.Alias+".conf")
|
||||
configPath = GetSitePath(website, SiteConf)
|
||||
//TODO 删除下面的代码
|
||||
case constant.ConfigFPM:
|
||||
runtimeInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID))
|
||||
if err != nil {
|
||||
return response.FileInfo{}, err
|
||||
return nil, err
|
||||
}
|
||||
configPath = path.Join(runtimeInstall.GetPath(), "conf", "php-fpm.conf")
|
||||
case constant.ConfigPHP:
|
||||
runtimeInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID))
|
||||
if err != nil {
|
||||
return response.FileInfo{}, err
|
||||
return nil, err
|
||||
}
|
||||
configPath = path.Join(runtimeInstall.GetPath(), "conf", "php.ini")
|
||||
}
|
||||
|
|
@ -928,9 +909,9 @@ func (w WebsiteService) GetWebsiteNginxConfig(websiteId uint, configType string)
|
|||
Expand: true,
|
||||
})
|
||||
if err != nil {
|
||||
return response.FileInfo{}, err
|
||||
return nil, err
|
||||
}
|
||||
return response.FileInfo{FileInfo: *info}, nil
|
||||
return &response.FileInfo{FileInfo: *info}, nil
|
||||
}
|
||||
|
||||
func (w WebsiteService) GetWebsiteHTTPS(websiteId uint) (response.WebsiteHTTPS, error) {
|
||||
|
|
@ -1633,12 +1614,8 @@ func (w WebsiteService) UpdateRewriteConfig(req request.NginxRewriteUpdate) erro
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nginxFull, err := getNginxFull(&website)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
includePath := fmt.Sprintf("/www/sites/%s/rewrite/%s.conf", website.Alias, website.PrimaryDomain)
|
||||
absolutePath := path.Join(nginxFull.Install.GetPath(), includePath)
|
||||
includePath := fmt.Sprintf("/www/sites/%s/rewrite/%s.conf", website.Alias, website.Alias)
|
||||
absolutePath := GetSitePath(website, SiteReWritePath)
|
||||
fileOp := files.NewFileOp()
|
||||
var oldRewriteContent []byte
|
||||
if !fileOp.Stat(path.Dir(absolutePath)) {
|
||||
|
|
@ -1675,11 +1652,7 @@ func (w WebsiteService) GetRewriteConfig(req request.NginxRewriteReq) (*response
|
|||
}
|
||||
var contentByte []byte
|
||||
if req.Name == "current" {
|
||||
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rewriteConfPath := path.Join(nginxInstall.GetPath(), "www", "sites", website.Alias, "rewrite", fmt.Sprintf("%s.conf", website.PrimaryDomain))
|
||||
rewriteConfPath := GetSitePath(website, SiteReWritePath)
|
||||
fileOp := files.NewFileOp()
|
||||
if fileOp.Stat(rewriteConfPath) {
|
||||
contentByte, err = fileOp.GetContent(rewriteConfPath)
|
||||
|
|
@ -1743,42 +1716,44 @@ func (w WebsiteService) UpdateSitePermission(req request.WebsiteUpdateDirPermiss
|
|||
|
||||
func (w WebsiteService) OperateProxy(req request.WebsiteProxyConfig) (err error) {
|
||||
var (
|
||||
website model.Website
|
||||
params []response.NginxParam
|
||||
nginxInstall model.AppInstall
|
||||
par *parser.Parser
|
||||
oldContent []byte
|
||||
website model.Website
|
||||
//params []response.NginxParam
|
||||
//nginxInstall model.AppInstall
|
||||
par *parser.Parser
|
||||
oldContent []byte
|
||||
)
|
||||
|
||||
website, err = websiteRepo.GetFirst(commonRepo.WithByID(req.ID))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
params, err = getNginxParamsByKeys(constant.NginxScopeHttp, []string{"proxy_cache"}, &website)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
nginxInstall, err = getAppInstallByKey(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
//params, err = getNginxParamsByKeys(constant.NginxScopeHttp, []string{"proxy_cache"}, &website)
|
||||
//if err != nil {
|
||||
// return
|
||||
//}
|
||||
//nginxInstall, err = getAppInstallByKey(constant.AppOpenresty)
|
||||
//if err != nil {
|
||||
// return
|
||||
//}
|
||||
fileOp := files.NewFileOp()
|
||||
if len(params) == 0 || len(params[0].Params) == 0 {
|
||||
commonDir := path.Join(nginxInstall.GetPath(), "www", "common", "proxy")
|
||||
proxyTempPath := path.Join(commonDir, "proxy_temp_dir")
|
||||
if !fileOp.Stat(proxyTempPath) {
|
||||
_ = fileOp.CreateDir(proxyTempPath, 0755)
|
||||
}
|
||||
proxyCacheDir := path.Join(commonDir, "proxy_temp_dir")
|
||||
if !fileOp.Stat(proxyCacheDir) {
|
||||
_ = fileOp.CreateDir(proxyCacheDir, 0755)
|
||||
}
|
||||
nginxParams := getNginxParamsFromStaticFile(dto.CACHE, nil)
|
||||
if err = updateNginxConfig(constant.NginxScopeHttp, nginxParams, &website); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
includeDir := path.Join(nginxInstall.GetPath(), "www", "sites", website.Alias, "proxy")
|
||||
//TODO 代理缓存改为单独使用配置
|
||||
//if len(params) == 0 || len(params[0].Params) == 0 {
|
||||
// commonDir := path.Join(nginxInstall.GetPath(), "www", "common", "proxy")
|
||||
// proxyTempPath := path.Join(commonDir, "proxy_temp_dir")
|
||||
// if !fileOp.Stat(proxyTempPath) {
|
||||
// _ = fileOp.CreateDir(proxyTempPath, 0755)
|
||||
// }
|
||||
// proxyCacheDir := path.Join(commonDir, "proxy_temp_dir")
|
||||
// if !fileOp.Stat(proxyCacheDir) {
|
||||
// _ = fileOp.CreateDir(proxyCacheDir, 0755)
|
||||
// }
|
||||
// nginxParams := getNginxParamsFromStaticFile(dto.CACHE, nil)
|
||||
// if err = updateNginxConfig(constant.NginxScopeHttp, nginxParams, &website); err != nil {
|
||||
// return
|
||||
// }
|
||||
//}
|
||||
|
||||
includeDir := GetSitePath(website, SiteProxyDir)
|
||||
if !fileOp.Stat(includeDir) {
|
||||
_ = fileOp.CreateDir(includeDir, 0755)
|
||||
}
|
||||
|
|
@ -1873,19 +1848,14 @@ func (w WebsiteService) OperateProxy(req request.WebsiteProxyConfig) (err error)
|
|||
|
||||
func (w WebsiteService) GetProxies(id uint) (res []request.WebsiteProxyConfig, err error) {
|
||||
var (
|
||||
website model.Website
|
||||
nginxInstall model.AppInstall
|
||||
fileList response.FileInfo
|
||||
website model.Website
|
||||
fileList response.FileInfo
|
||||
)
|
||||
website, err = websiteRepo.GetFirst(commonRepo.WithByID(id))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
nginxInstall, err = getAppInstallByKey(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
includeDir := path.Join(nginxInstall.GetPath(), "www", "sites", website.Alias, "proxy")
|
||||
includeDir := GetSitePath(website, SiteProxyDir)
|
||||
fileOp := files.NewFileOp()
|
||||
if !fileOp.Stat(includeDir) {
|
||||
return
|
||||
|
|
@ -2456,20 +2426,15 @@ func (w WebsiteService) GetAntiLeech(id uint) (*response.NginxAntiLeechRes, erro
|
|||
|
||||
func (w WebsiteService) OperateRedirect(req request.NginxRedirectReq) (err error) {
|
||||
var (
|
||||
website model.Website
|
||||
nginxInstall model.AppInstall
|
||||
oldContent []byte
|
||||
website model.Website
|
||||
oldContent []byte
|
||||
)
|
||||
|
||||
website, err = websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nginxInstall, err = getAppInstallByKey(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
includeDir := path.Join(nginxInstall.GetPath(), "www", "sites", website.Alias, "redirect")
|
||||
includeDir := GetSitePath(website, SiteRedirectDir)
|
||||
fileOp := files.NewFileOp()
|
||||
if !fileOp.Stat(includeDir) {
|
||||
_ = fileOp.CreateDir(includeDir, 0755)
|
||||
|
|
@ -2610,19 +2575,14 @@ func (w WebsiteService) OperateRedirect(req request.NginxRedirectReq) (err error
|
|||
|
||||
func (w WebsiteService) GetRedirect(id uint) (res []response.NginxRedirectConfig, err error) {
|
||||
var (
|
||||
website model.Website
|
||||
nginxInstall model.AppInstall
|
||||
fileList response.FileInfo
|
||||
website model.Website
|
||||
fileList response.FileInfo
|
||||
)
|
||||
website, err = websiteRepo.GetFirst(commonRepo.WithByID(id))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
nginxInstall, err = getAppInstallByKey(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
includeDir := path.Join(nginxInstall.GetPath(), "www", "sites", website.Alias, "redirect")
|
||||
includeDir := GetSitePath(website, SiteRedirectDir)
|
||||
fileOp := files.NewFileOp()
|
||||
if !fileOp.Stat(includeDir) {
|
||||
return
|
||||
|
|
@ -2780,11 +2740,7 @@ func (w WebsiteService) LoadWebsiteDirConfig(req request.WebsiteCommonReq) (*res
|
|||
return nil, err
|
||||
}
|
||||
res := &response.WebsiteDirConfig{}
|
||||
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
absoluteIndexPath := path.Join(nginxInstall.GetPath(), "www", "sites", website.Alias, "index")
|
||||
absoluteIndexPath := GetSitePath(website, SiteIndexDir)
|
||||
var appFs = afero.NewOsFs()
|
||||
info, err := appFs.Stat(absoluteIndexPath)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -541,16 +541,7 @@ func removeSSLListen(website model.Website, binds []string) error {
|
|||
}
|
||||
|
||||
func createPemFile(website model.Website, websiteSSL model.WebsiteSSL) error {
|
||||
nginxApp, err := appRepo.GetFirst(appRepo.WithKey(constant.AppOpenresty))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nginxInstall, err := appInstallRepo.GetFirst(appInstallRepo.WithAppId(nginxApp.ID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
configDir := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", website.Alias, "ssl")
|
||||
configDir := GetSitePath(website, SiteSSLDir)
|
||||
fileOp := files.NewFileOp()
|
||||
|
||||
if !fileOp.Stat(configDir) {
|
||||
|
|
@ -1160,3 +1151,56 @@ func getResourceContent(fileOp files.FileOp, resourcePath string) (string, error
|
|||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func GetWebSiteRootDir() string {
|
||||
siteSetting, _ := settingRepo.Get(settingRepo.WithByKey("WEBSITE_DIR"))
|
||||
dir := siteSetting.Value
|
||||
if dir == "" {
|
||||
dir = path.Join(constant.DataDir, "www")
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
func GteSiteDir(alias string) string {
|
||||
return path.Join(GetWebSiteRootDir(), "sites", alias)
|
||||
}
|
||||
|
||||
const (
|
||||
SiteConf = "SiteConf"
|
||||
SiteAccessLog = "access.log"
|
||||
SiteErrorLog = "error.log"
|
||||
WebsiteRootDir = "WebsiteRootDir"
|
||||
SiteDir = "SiteDir"
|
||||
SiteIndexDir = "SiteIndexDir"
|
||||
SiteProxyDir = "SiteProxyDir"
|
||||
SiteSSLDir = "SiteSSLDir"
|
||||
SiteReWritePath = "SiteReWritePath"
|
||||
SiteRedirectDir = "SiteRedirectDir"
|
||||
)
|
||||
|
||||
func GetSitePath(website model.Website, confType string) string {
|
||||
switch confType {
|
||||
case SiteConf:
|
||||
return path.Join(GetWebSiteRootDir(), "conf.d", website.Alias+".conf")
|
||||
case SiteAccessLog:
|
||||
return path.Join(GteSiteDir(website.Alias), "log", "access.log")
|
||||
case SiteErrorLog:
|
||||
return path.Join(GteSiteDir(website.Alias), "log", "error.log")
|
||||
case WebsiteRootDir:
|
||||
return GetWebSiteRootDir()
|
||||
case SiteDir:
|
||||
return GteSiteDir(website.Alias)
|
||||
case SiteIndexDir:
|
||||
return path.Join(GteSiteDir(website.Alias), "index")
|
||||
case SiteProxyDir:
|
||||
return path.Join(GteSiteDir(website.Alias), "proxy")
|
||||
case SiteSSLDir:
|
||||
return path.Join(GteSiteDir(website.Alias), "ssl")
|
||||
case SiteReWritePath:
|
||||
return path.Join(GteSiteDir(website.Alias), "rewrite", website.Alias+".conf")
|
||||
case SiteRedirectDir:
|
||||
return path.Join(GteSiteDir(website.Alias), "redirect")
|
||||
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,29 +91,10 @@
|
|||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
<div v-if="!data.isExist && !isDB()">
|
||||
<LayoutContent :title="getTitle(key)" :divider="true">
|
||||
<template #main>
|
||||
<div class="app-warn">
|
||||
<div class="flx-center">
|
||||
<span>{{ $t('app.checkInstalledWarn', [data.app]) }}</span>
|
||||
<span @click="goRouter(key)" class="flx-align-center">
|
||||
<el-icon class="ml-2"><Position /></el-icon>
|
||||
{{ $t('database.goInstall') }}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<img src="@/assets/images/no_app.svg" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</LayoutContent>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { CheckAppInstalled, InstalledOp } from '@/api/modules/app';
|
||||
import router from '@/routers';
|
||||
import { onMounted, reactive, ref, watch } from 'vue';
|
||||
import Status from '@/components/status/index.vue';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
|
|
@ -172,14 +153,6 @@ const setting = () => {
|
|||
em('setting', false);
|
||||
};
|
||||
|
||||
const goRouter = async (key: string) => {
|
||||
router.push({ name: 'AppAll', query: { install: key } });
|
||||
};
|
||||
|
||||
const isDB = () => {
|
||||
return key.value === 'mysql' || key.value === 'mariadb' || key.value === 'postgresql';
|
||||
};
|
||||
|
||||
const onCheck = async () => {
|
||||
await CheckAppInstalled(key.value, name.value)
|
||||
.then((res) => {
|
||||
|
|
@ -239,19 +212,6 @@ const onOperate = async (operation: string) => {
|
|||
});
|
||||
};
|
||||
|
||||
const getTitle = (key: string) => {
|
||||
switch (key) {
|
||||
case 'openresty':
|
||||
return i18n.global.t('website.website');
|
||||
case 'mysql':
|
||||
return 'MySQL ' + i18n.global.t('menu.database');
|
||||
case 'postgresql':
|
||||
return 'PostgreSQL ' + i18n.global.t('menu.database');
|
||||
case 'redis':
|
||||
return 'Redis ' + i18n.global.t('menu.database');
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
key.value = props.appKey;
|
||||
name.value = props.appName;
|
||||
|
|
|
|||
|
|
@ -18,22 +18,27 @@
|
|||
@is-exist="checkExist"
|
||||
></AppStatus>
|
||||
</template>
|
||||
<template v-if="nginxIsExist && !openNginxConfig" #leftToolBar>
|
||||
<el-button type="primary" @click="openCreate">
|
||||
<template v-if="!openNginxConfig" #leftToolBar>
|
||||
<el-button type="primary" @click="openCreate" :disabled="nginxStatus != 'Running'">
|
||||
{{ $t('website.create') }}
|
||||
</el-button>
|
||||
<el-button type="primary" plain @click="openGroup">
|
||||
<el-button type="primary" plain @click="openGroup" :disabled="nginxStatus != 'Running'">
|
||||
{{ $t('website.group') }}
|
||||
</el-button>
|
||||
<el-button type="primary" plain @click="openDefault">
|
||||
<el-button type="primary" plain @click="openDefault" :disabled="nginxStatus != 'Running'">
|
||||
{{ $t('website.defaultServer') }}
|
||||
</el-button>
|
||||
<el-button type="primary" plain @click="openDefaultHtml">
|
||||
<el-button type="primary" plain @click="openDefaultHtml" :disabled="nginxStatus != 'Running'">
|
||||
{{ $t('website.defaultHtml') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-if="nginxIsExist && !openNginxConfig" #rightToolBar>
|
||||
<el-select v-model="req.websiteGroupId" @change="search()" class="p-w-200 mr-2.5">
|
||||
<template v-if="!openNginxConfig" #rightToolBar>
|
||||
<el-select
|
||||
v-model="req.websiteGroupId"
|
||||
@change="search()"
|
||||
class="p-w-200 mr-2.5"
|
||||
:disabled="nginxStatus != 'Running'"
|
||||
>
|
||||
<template #prefix>{{ $t('website.group') }}</template>
|
||||
<el-option :label="$t('commons.table.all')" :value="0"></el-option>
|
||||
<el-option
|
||||
|
|
@ -54,7 +59,7 @@
|
|||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="nginxIsExist && !openNginxConfig" #main>
|
||||
<template v-if="!openNginxConfig" #main>
|
||||
<ComplexTable
|
||||
:pagination-config="paginationConfig"
|
||||
:data="data"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue