mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-07-01 02:04:33 +08:00
debug(sitecheck): exploration #1463
This commit is contained in:
@@ -3,19 +3,26 @@ package site
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
)
|
||||
|
||||
// GetSiteStatus returns the status of the site
|
||||
func GetSiteStatus(name string) Status {
|
||||
enabledFilePath := nginx.GetConfSymlinkPath(nginx.GetConfPath("sites-enabled", name))
|
||||
if helper.FileExists(enabledFilePath) {
|
||||
enabledExists := helper.FileExists(enabledFilePath)
|
||||
if enabledExists {
|
||||
return StatusEnabled
|
||||
}
|
||||
|
||||
mantainanceFilePath := nginx.GetConfPath("sites-enabled", name+MaintenanceSuffix)
|
||||
if helper.FileExists(mantainanceFilePath) {
|
||||
maintenanceExists := helper.FileExists(mantainanceFilePath)
|
||||
if maintenanceExists {
|
||||
return StatusMaintenance
|
||||
}
|
||||
|
||||
logger.Debugf(
|
||||
"Site %s considered disabled (enabledPath=%s exists=%t, maintenancePath=%s exists=%t)",
|
||||
name, enabledFilePath, enabledExists, mantainanceFilePath, maintenanceExists,
|
||||
)
|
||||
return StatusDisabled
|
||||
}
|
||||
|
||||
@@ -101,20 +101,20 @@ func (sc *SiteChecker) CollectSites() {
|
||||
// Check site status - only collect from enabled sites
|
||||
siteStatus := site.GetSiteStatus(siteName)
|
||||
if siteStatus != site.StatusEnabled {
|
||||
// logger.Debugf("Skipping site %s (status: %s) - only collecting from enabled sites", siteName, siteStatus)
|
||||
logger.Debugf("Skipping site %s (status: %s) - only collecting from enabled sites", siteName, siteStatus)
|
||||
continue
|
||||
}
|
||||
|
||||
// logger.Debugf("Processing enabled site: %s with %d URLs", siteName, len(indexedSite.Urls))
|
||||
logger.Debugf("Processing enabled site: %s with %d URLs", siteName, len(indexedSite.Urls))
|
||||
for _, url := range indexedSite.Urls {
|
||||
if url != "" {
|
||||
// logger.Debugf("Adding site URL: %s", url)
|
||||
logger.Debugf("Adding site URL: %s", url)
|
||||
// Load site config to determine display URL
|
||||
config, err := LoadSiteConfig(url)
|
||||
protocol := "http" // default protocol
|
||||
if err == nil && config != nil && config.HealthCheckConfig != nil && config.HealthCheckConfig.Protocol != "" {
|
||||
protocol = config.HealthCheckConfig.Protocol
|
||||
// logger.Debugf("Site %s using protocol: %s", url, protocol)
|
||||
logger.Debugf("Site %s using protocol: %s", url, protocol)
|
||||
} else {
|
||||
logger.Debugf("Site %s using default protocol: %s (config error: %v)", url, protocol, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user