rename config variable

This commit is contained in:
Cyberes 2024-03-17 20:33:32 -06:00
parent 6a7153b92b
commit 56be07c0a7
4 changed files with 8 additions and 8 deletions

View File

@ -6,7 +6,7 @@ watch_mode: crawl
crawl_mode_crawl_interval: 3600 # seconds crawl_mode_crawl_interval: 3600 # seconds
watch_interval: 2 # seconds watch_interval: 2 # seconds
directory_crawlers: 10 directory_crawl_workers: 10
crawl_workers: 1000 crawl_workers: 1000
cache_size: 100000000 cache_size: 100000000

View File

@ -59,7 +59,7 @@ func APIAdminCrawlsInfo(w http.ResponseWriter, r *http.Request) {
}, },
"crawlWorkers": map[string]interface{}{ "crawlWorkers": map[string]interface{}{
"busy": atomic.LoadInt32(&globals.DirectoryCrawlers.BusyWorkers), "busy": atomic.LoadInt32(&globals.DirectoryCrawlers.BusyWorkers),
"alive": config.GetConfig().DirectoryCrawlers, "alive": config.GetConfig().DirectoryCrawlWorkers,
}, },
"queue": map[string]interface{}{ "queue": map[string]interface{}{
"items": globals.DirectoryCrawlers.Queue.GetQueuedJobs(), "items": globals.DirectoryCrawlers.Queue.GetQueuedJobs(),

View File

@ -13,7 +13,7 @@ type Config struct {
RootDir string RootDir string
HTTPPort string HTTPPort string
CrawlModeCrawlInterval int CrawlModeCrawlInterval int
DirectoryCrawlers int DirectoryCrawlWorkers int
CacheSize int CacheSize int
CacheTime int // TODO: does this do anything? CacheTime int // TODO: does this do anything?
CachePrintNew bool CachePrintNew bool
@ -58,7 +58,7 @@ func SetConfig(configFile string) (*Config, error) {
viper.SetDefault("watch_interval", 1) viper.SetDefault("watch_interval", 1)
viper.SetDefault("watch_mode", "crawl") viper.SetDefault("watch_mode", "crawl")
viper.SetDefault("crawl_mode_crawl_interval", 3600) viper.SetDefault("crawl_mode_crawl_interval", 3600)
viper.SetDefault("directory_crawlers", 10) viper.SetDefault("directory_crawl_workers", 10)
viper.SetDefault("cache_size", 100000000) viper.SetDefault("cache_size", 100000000)
viper.SetDefault("cache_time", 30) viper.SetDefault("cache_time", 30)
viper.SetDefault("cache_print_new", false) viper.SetDefault("cache_print_new", false)
@ -115,7 +115,7 @@ func SetConfig(configFile string) (*Config, error) {
RootDir: rootDir, RootDir: rootDir,
HTTPPort: viper.GetString("http_port"), HTTPPort: viper.GetString("http_port"),
CrawlModeCrawlInterval: viper.GetInt("crawl_mode_crawl_interval"), CrawlModeCrawlInterval: viper.GetInt("crawl_mode_crawl_interval"),
DirectoryCrawlers: viper.GetInt("directory_crawlers"), DirectoryCrawlWorkers: viper.GetInt("directory_crawl_workers"),
CacheSize: viper.GetInt("cache_size"), CacheSize: viper.GetInt("cache_size"),
CacheTime: viper.GetInt("cache_time"), CacheTime: viper.GetInt("cache_time"),
CachePrintNew: viper.GetBool("cache_print_new"), CachePrintNew: viper.GetBool("cache_print_new"),
@ -153,7 +153,7 @@ func SetConfig(configFile string) (*Config, error) {
return nil, errors.New("cache_time must be a positive number") return nil, errors.New("cache_time must be a positive number")
} }
if config.DirectoryCrawlers < 1 { if config.DirectoryCrawlWorkers < 1 {
return nil, errors.New("crawl_mode_crawl_interval must be greater than or equal to 1") return nil, errors.New("crawl_mode_crawl_interval must be greater than or equal to 1")
} }

View File

@ -11,7 +11,7 @@ func InitializeDirectoryCrawlerWorkers() *globals.DcWorkers {
if globals.DirectoryCrawlers != nil { if globals.DirectoryCrawlers != nil {
panic("DirectoryCrawlers has already been defined!") panic("DirectoryCrawlers has already been defined!")
} }
dcWorkers := workers.InitializeWorkers(config.GetConfig().DirectoryCrawlers, directoryCrawlerWorker) dcWorkers := workers.InitializeWorkers(config.GetConfig().DirectoryCrawlWorkers, directoryCrawlerWorker)
d := &globals.DcWorkers{} d := &globals.DcWorkers{}
// Copy the fields given to us by InitializeWorkers() to the global object. // Copy the fields given to us by InitializeWorkers() to the global object.
@ -19,7 +19,7 @@ func InitializeDirectoryCrawlerWorkers() *globals.DcWorkers {
dcWorkers.BusyWorkers = &d.BusyWorkers dcWorkers.BusyWorkers = &d.BusyWorkers
globals.DirectoryCrawlers = d globals.DirectoryCrawlers = d
log.Debugf("CRAWLERS - Started %d directory crawler workers.", config.GetConfig().DirectoryCrawlers) log.Debugf("CRAWLERS - Started %d directory crawler workers.", config.GetConfig().DirectoryCrawlWorkers)
return d return d
} }