minor cleanup

This commit is contained in:
Cyberes 2023-12-13 14:43:57 -07:00
parent 631844fb98
commit cd4364436a
5 changed files with 12 additions and 10 deletions

View File

@ -30,8 +30,8 @@ func AdminCacheInfo(w http.ResponseWriter, r *http.Request) {
"cachedItems": cacheLen, "cachedItems": cacheLen,
"cacheMax": config.GetConfig().CacheSize, "cacheMax": config.GetConfig().CacheSize,
"recacheCrawlLimit": config.GetConfig().CacheRecacheCrawlerLimit, "recacheCrawlLimit": config.GetConfig().CacheRecacheCrawlerLimit,
"newSyncRunning": elastic.ElasticRefreshSyncRunning, "newSyncRunning": elastic.FullSyncRunning,
"refreshSyncRunning": elastic.ElasticRefreshSyncRunning, "refreshSyncRunning": elastic.FullSyncRunning,
} }
w.Header().Set("Cache-Control", "no-store") w.Header().Set("Cache-Control", "no-store")
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")

View File

@ -57,7 +57,7 @@ func logCacheStatus(msg string, ticker *time.Ticker, logFn func(format string, a
logFn(logStr, logFn(logStr,
msg, len(SharedCache.Cache.Keys()), config.GetConfig().CacheSize, Workers.BusyWorkers, Workers.Queue.GetQueueSize(), DirectoryCrawler.GetTotalActiveCrawls()) msg, len(SharedCache.Cache.Keys()), config.GetConfig().CacheSize, Workers.BusyWorkers, Workers.Queue.GetQueueSize(), DirectoryCrawler.GetTotalActiveCrawls())
} else { } else {
logStr := "%s - %d/%d items in the cache. Busy Workers: %d. Jobs queued: %d. Running crawls: %d. Busy Elastic sync workers: %d. Elastic sync queued: %d" logStr := "%s - %d/%d items in the cache. Busy Workers: %d. Jobs queued: %d. Running crawls: %d. Busy Elastic delete workers: %d. Elastic deletes queued: %d"
logFn(logStr, logFn(logStr,
msg, len(SharedCache.Cache.Keys()), config.GetConfig().CacheSize, Workers.BusyWorkers, Workers.Queue.GetQueueSize(), DirectoryCrawler.GetTotalActiveCrawls(), elastic.BusyWorkers, elastic.Queue.GetQueueSize()) msg, len(SharedCache.Cache.Keys()), config.GetConfig().CacheSize, Workers.BusyWorkers, Workers.Queue.GetQueueSize(), DirectoryCrawler.GetTotalActiveCrawls(), elastic.BusyWorkers, elastic.Queue.GetQueueSize())
} }

View File

@ -25,7 +25,7 @@ func worker() {
atomic.AddInt32(&BusyWorkers, 1) atomic.AddInt32(&BusyWorkers, 1)
if _, ok := SharedCache.Cache.Get(job.Key); !ok { if _, ok := SharedCache.Cache.Get(job.Key); !ok {
// If a key does not exist in the LRU cache, delete it from Elasticsearch // If a key in Elastic does not exist in the LRU cache, delete it from Elastic.
deleteFromElasticsearch(job.Key) deleteFromElasticsearch(job.Key)
log.Debugf(`ELASTIC - Removed key "%s"`, job.Key) log.Debugf(`ELASTIC - Removed key "%s"`, job.Key)
} }

View File

@ -46,10 +46,10 @@ func syncElasticsearch(doFullSync bool) {
var syncType string var syncType string
if fullSync { if fullSync {
ElasticRefreshSyncRunning = true FullSyncRunning = true
syncType = "full refresh" syncType = "full refresh"
} else { } else {
ElasticNewSyncRunning = true RefreshSyncRunning = true
syncType = "refresh" syncType = "refresh"
} }
@ -77,6 +77,8 @@ func syncElasticsearch(doFullSync bool) {
duration := time.Since(start) duration := time.Since(start)
log.Infof("ELASTIC - %s sync finished in %s", syncType, duration) log.Infof("ELASTIC - %s sync finished in %s", syncType, duration)
FullSyncRunning = false
RefreshSyncRunning = false
syncLock.Unlock() syncLock.Unlock()
} }

View File

@ -9,11 +9,11 @@ import (
var log *logrus.Logger var log *logrus.Logger
var ElasticClient *elasticsearch.Client var ElasticClient *elasticsearch.Client
var ElasticNewSyncRunning bool var RefreshSyncRunning bool
var ElasticRefreshSyncRunning bool var FullSyncRunning bool
func init() { func init() {
log = logging.GetLogger() log = logging.GetLogger()
ElasticNewSyncRunning = false RefreshSyncRunning = false
ElasticRefreshSyncRunning = false FullSyncRunning = false
} }