rename config variable

This commit is contained in:
Cyberes 2024-03-17 20:32:12 -06:00
parent b70c830d18
commit 6a7153b92b
5 changed files with 9 additions and 9 deletions

View File

@ -41,7 +41,7 @@ func APIAdminCrawlsInfo(w http.ResponseWriter, r *http.Request) {
// If no sync is running then these vars will not exist. // If no sync is running then these vars will not exist.
elasticWorkers = map[string]interface{}{ elasticWorkers = map[string]interface{}{
"busy": globals.ElasticCrawlers.BusyWorkers, "busy": globals.ElasticCrawlers.BusyWorkers,
"alive": config.GetConfig().ElasticsearchSyncThreads, "alive": config.GetConfig().ElasticsearchSyncWorkers,
"queueSize": globals.ElasticCrawlers.Queue.GetQueuedJobs(), "queueSize": globals.ElasticCrawlers.Queue.GetQueuedJobs(),
} }
} else { } else {

View File

@ -37,7 +37,7 @@ type Config struct {
ElasticsearchFullSyncInterval int ElasticsearchFullSyncInterval int
ElasticsearchAPIKey string ElasticsearchAPIKey string
ElasticsearchIndex string ElasticsearchIndex string
ElasticsearchSyncThreads int ElasticsearchSyncWorkers int
ElasticsearchExcludePatterns []string ElasticsearchExcludePatterns []string
ElasticsearchFullSyncOnStart bool ElasticsearchFullSyncOnStart bool
ElasticsearchDefaultQueryField string ElasticsearchDefaultQueryField string
@ -83,7 +83,7 @@ func SetConfig(configFile string) (*Config, error) {
viper.SetDefault("elasticsearch_full_sync_interval", 86400) viper.SetDefault("elasticsearch_full_sync_interval", 86400)
viper.SetDefault("elasticsearch_api_key", "") viper.SetDefault("elasticsearch_api_key", "")
viper.SetDefault("elasticsearch_index", "crazyfs_search") viper.SetDefault("elasticsearch_index", "crazyfs_search")
viper.SetDefault("elasticsearch_sync_threads", 50) viper.SetDefault("elasticsearch_sync_workers", 50)
viper.SetDefault("elasticsearch_exclude_patterns", []string{".git"}) viper.SetDefault("elasticsearch_exclude_patterns", []string{".git"})
viper.SetDefault("elasticsearch_allow_concurrent_syncs", false) viper.SetDefault("elasticsearch_allow_concurrent_syncs", false)
viper.SetDefault("elasticsearch_full_sync_on_start", false) viper.SetDefault("elasticsearch_full_sync_on_start", false)
@ -139,7 +139,7 @@ func SetConfig(configFile string) (*Config, error) {
ElasticsearchFullSyncInterval: viper.GetInt("elasticsearch_full_sync_interval"), ElasticsearchFullSyncInterval: viper.GetInt("elasticsearch_full_sync_interval"),
ElasticsearchAPIKey: viper.GetString("elasticsearch_api_key"), ElasticsearchAPIKey: viper.GetString("elasticsearch_api_key"),
ElasticsearchIndex: viper.GetString("elasticsearch_index"), ElasticsearchIndex: viper.GetString("elasticsearch_index"),
ElasticsearchSyncThreads: viper.GetInt("elasticsearch_sync_threads"), ElasticsearchSyncWorkers: viper.GetInt("elasticsearch_sync_workers"),
ElasticsearchExcludePatterns: viper.GetStringSlice("elasticsearch_exclude_patterns"), ElasticsearchExcludePatterns: viper.GetStringSlice("elasticsearch_exclude_patterns"),
ElasticsearchFullSyncOnStart: viper.GetBool("elasticsearch_full_sync_on_start"), ElasticsearchFullSyncOnStart: viper.GetBool("elasticsearch_full_sync_on_start"),
ElasticsearchDefaultQueryField: viper.GetString("elasticsearch_default_query_field"), ElasticsearchDefaultQueryField: viper.GetString("elasticsearch_default_query_field"),

View File

@ -116,14 +116,14 @@ func main() {
// Start the Elastic connection, so it can initialize while we're doing the initial crawl. // Start the Elastic connection, so it can initialize while we're doing the initial crawl.
// If we fail to establish a connection to Elastic, don't kill the entire server. Instead, just disable Elastic. // If we fail to establish a connection to Elastic, don't kill the entire server. Instead, just disable Elastic.
if cfg.ElasticsearchEnable && !cliArgs.disableElasticSync { if cfg.ElasticsearchEnable && !cliArgs.disableElasticSync {
fmt.Println(config.GetConfig().ElasticsearchSyncThreads + 1) fmt.Println(config.GetConfig().ElasticsearchSyncWorkers + 1)
esCfg := elasticsearch.Config{ esCfg := elasticsearch.Config{
Addresses: []string{ Addresses: []string{
cfg.ElasticsearchEndpoint, cfg.ElasticsearchEndpoint,
}, },
APIKey: cfg.ElasticsearchAPIKey, APIKey: cfg.ElasticsearchAPIKey,
//Transport: &http.Transport{ //Transport: &http.Transport{
// MaxIdleConnsPerHost: config.GetConfig().ElasticsearchSyncThreads + 1, // MaxIdleConnsPerHost: config.GetConfig().ElasticsearchSyncWorkers + 1,
// IdleConnTimeout: 30 * time.Second, // IdleConnTimeout: 30 * time.Second,
//}, //},
} }

View File

@ -25,7 +25,7 @@ func InitializeElasticCrawlerWorkers() *globals.DcWorkers {
if globals.ElasticCrawlers != nil { if globals.ElasticCrawlers != nil {
panic("ElasticCrawlers has already been defined!") panic("ElasticCrawlers has already been defined!")
} }
elWorkers := workers.InitializeWorkers(config.GetConfig().ElasticsearchSyncThreads, elasticDeleteWorker) elWorkers := workers.InitializeWorkers(config.GetConfig().ElasticsearchSyncWorkers, elasticDeleteWorker)
d := &globals.DcWorkers{} d := &globals.DcWorkers{}
d.Queue = elWorkers.Queue d.Queue = elWorkers.Queue
extra := make(map[string]interface{}) extra := make(map[string]interface{})
@ -34,7 +34,7 @@ func InitializeElasticCrawlerWorkers() *globals.DcWorkers {
d.Extra = &CrawlerExtras{} d.Extra = &CrawlerExtras{}
elWorkers.BusyWorkers = &d.BusyWorkers elWorkers.BusyWorkers = &d.BusyWorkers
globals.ElasticCrawlers = d globals.ElasticCrawlers = d
log.Debugf("CRAWLERS - Started %d Elasticsearch sync workers.", config.GetConfig().ElasticsearchSyncThreads) log.Debugf("CRAWLERS - Started %d Elasticsearch sync workers.", config.GetConfig().ElasticsearchSyncWorkers)
return d return d
} }

View File

@ -150,7 +150,7 @@ func EnableElasticsearchConnection() {
return return
} }
Enabled = true Enabled = true
//http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = config.GetConfig().ElasticsearchSyncThreads //http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = config.GetConfig().ElasticsearchSyncWorkers
log.Infof(`ELASTIC - Connected to index "%s".`, config.GetConfig().ElasticsearchIndex) log.Infof(`ELASTIC - Connected to index "%s".`, config.GetConfig().ElasticsearchIndex)
} }