fix kernal panic

This commit is contained in:
Cyberes 2024-01-23 10:41:01 -07:00
parent 3af85db036
commit d925847734
2 changed files with 5 additions and 6 deletions

View File

@ -90,9 +90,7 @@ func main() {
// Set global variables. // Set global variables.
config.FollowSymlinks = false // TODO: make sure this works then set it based on the config yml config.FollowSymlinks = false // TODO: make sure this works then set it based on the config yml
log.Infof("Elasticsearch enabled: %t", cfg.ElasticsearchEnable) // 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 { if cfg.ElasticsearchEnable {
esCfg := elasticsearch.Config{ esCfg := elasticsearch.Config{
@ -108,15 +106,15 @@ func main() {
elastic.ElasticEnabled = false elastic.ElasticEnabled = false
} else { } else {
elastic.ElasticClient = es elastic.ElasticClient = es
elastic.InitializeWorkers()
// This could take a minute, so we do this in the background while we crawl.
go func() { go func() {
// This could take a minute, so we do this in the background while we crawl.
elastic.EnableElasticsearchConnection() elastic.EnableElasticsearchConnection()
for cache.InitialCrawlInProgress { for cache.InitialCrawlInProgress {
// Sleep while the initial crawl is running. // Sleep while the initial crawl is running.
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
} }
if !cliArgs.disableElasticSync || !cfg.ElasticsearchSyncEnable { if !cliArgs.disableElasticSync || !cfg.ElasticsearchSyncEnable {
elastic.InitializeWorkers()
go elastic.SyncThread() go elastic.SyncThread()
log.Info("Started the background Elasticsearch sync thread.") log.Info("Started the background Elasticsearch sync thread.")
} else { } else {
@ -126,6 +124,8 @@ func main() {
} }
} }
log.Infof("Elasticsearch enabled: %t", cfg.ElasticsearchEnable)
Workers.InitializeWorkers() Workers.InitializeWorkers()
cache.InitRecacheSemaphore(cfg.CacheRecacheCrawlerLimit) cache.InitRecacheSemaphore(cfg.CacheRecacheCrawlerLimit)

View File

@ -37,7 +37,6 @@ func SyncThread() {
} }
} }
// TODO: make this use workers instead of starting a million threads
// TODO: have the workers exit when the sync job is finished // TODO: have the workers exit when the sync job is finished
func syncElasticsearch(doFullSync bool) { func syncElasticsearch(doFullSync bool) {
if !ElasticEnabled { if !ElasticEnabled {