chore: use nginx.GetConfEntryPath() #1013

This commit is contained in:
Jacky 2025-05-07 11:53:56 +08:00
parent a75a5b7429
commit 1ba1da0d5d
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
3 changed files with 5 additions and 5 deletions

View file

@ -348,7 +348,7 @@ func (s *Scanner) scanSingleFile(filePath string) error {
if strings.Contains(includePath, "*") { if strings.Contains(includePath, "*") {
// If it's a relative path, make it absolute based on nginx config dir // If it's a relative path, make it absolute based on nginx config dir
if !filepath.IsAbs(includePath) { if !filepath.IsAbs(includePath) {
configDir := filepath.Dir(nginx.GetConfPath("", "")) configDir := filepath.Dir(nginx.GetConfPath())
includePath = filepath.Join(configDir, includePath) includePath = filepath.Join(configDir, includePath)
} }
@ -373,7 +373,7 @@ func (s *Scanner) scanSingleFile(filePath string) error {
// Handle single file include // Handle single file include
// If it's a relative path, make it absolute based on nginx config dir // If it's a relative path, make it absolute based on nginx config dir
if !filepath.IsAbs(includePath) { if !filepath.IsAbs(includePath) {
configDir := filepath.Dir(nginx.GetConfPath("", "")) configDir := filepath.Dir(nginx.GetConfPath())
includePath = filepath.Join(configDir, includePath) includePath = filepath.Join(configDir, includePath)
} }
@ -413,7 +413,7 @@ func (s *Scanner) ScanAllConfigs() error {
}() }()
// Get the main config file // Get the main config file
mainConfigPath := nginx.GetConfPath("", "nginx.conf") mainConfigPath := nginx.GetConfEntryPath()
err := s.scanSingleFile(mainConfigPath) err := s.scanSingleFile(mainConfigPath)
if err != nil { if err != nil {
logger.Error("Failed to scan main config:", err) logger.Error("Failed to scan main config:", err)

View file

@ -51,7 +51,7 @@ func GetNginxWorkerConfigInfo() (*NginxConfigInfo, error) {
}, },
} }
confPath := nginx.GetConfPath("nginx.conf") confPath := nginx.GetConfEntryPath()
if confPath == "" { if confPath == "" {
return nil, errors.New("failed to get nginx.conf path") return nil, errors.New("failed to get nginx.conf path")
} }

View file

@ -53,7 +53,7 @@ type PerfOpt struct {
// UpdatePerfOpt updates the Nginx performance optimization settings // UpdatePerfOpt updates the Nginx performance optimization settings
func UpdatePerfOpt(opt *PerfOpt) error { func UpdatePerfOpt(opt *PerfOpt) error {
confPath := nginx.GetConfPath("nginx.conf") confPath := nginx.GetConfEntryPath()
if confPath == "" { if confPath == "" {
return errors.New("failed to get nginx.conf path") return errors.New("failed to get nginx.conf path")
} }