mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-25 11:39:16 +08:00
34 lines
810 B
Go
34 lines
810 B
Go
|
package service
|
||
|
|
||
|
import (
|
||
|
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||
|
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||
|
"path"
|
||
|
)
|
||
|
|
||
|
type NginxService struct {
|
||
|
}
|
||
|
|
||
|
func (w NginxService) GetNginxConfig() (dto.FileInfo, error) {
|
||
|
nginxApp, err := appRepo.GetFirst(appRepo.WithKey("nginx"))
|
||
|
if err != nil {
|
||
|
return dto.FileInfo{}, err
|
||
|
}
|
||
|
nginxInstall, err := appInstallRepo.GetFirst(appInstallRepo.WithAppId(nginxApp.ID))
|
||
|
if err != nil {
|
||
|
return dto.FileInfo{}, err
|
||
|
}
|
||
|
|
||
|
configPath := path.Join(constant.AppInstallDir, "nginx", nginxInstall.Name, "conf", "nginx.conf")
|
||
|
|
||
|
info, err := files.NewFileInfo(files.FileOption{
|
||
|
Path: configPath,
|
||
|
Expand: true,
|
||
|
})
|
||
|
if err != nil {
|
||
|
return dto.FileInfo{}, err
|
||
|
}
|
||
|
return dto.FileInfo{FileInfo: *info}, nil
|
||
|
}
|