adjust logging, catch rare ResponseItem panic for later

This commit is contained in:
Cyberes 2024-01-23 11:49:34 -07:00
parent d925847734
commit 7004e3935c
2 changed files with 8 additions and 0 deletions

View File

@ -32,6 +32,12 @@ type ResponseItem struct {
} }
func NewResponseItem(cacheItem *CacheItem.Item) *ResponseItem { func NewResponseItem(cacheItem *CacheItem.Item) *ResponseItem {
defer func() {
if r := recover(); r != nil {
log.Fatalf("Recovered from panic: %s - %s", r, cacheItem.Path)
}
}()
item := &ResponseItem{ item := &ResponseItem{
Path: cacheItem.Path, Path: cacheItem.Path,
Name: cacheItem.Name, Name: cacheItem.Name,

View File

@ -27,6 +27,8 @@ func SyncThread() {
ticker := time.NewTicker(time.Duration(config.GetConfig().ElasticsearchSyncInterval) * time.Second) ticker := time.NewTicker(time.Duration(config.GetConfig().ElasticsearchSyncInterval) * time.Second)
fullSyncTicker := time.NewTicker(time.Duration(config.GetConfig().ElasticsearchFullSyncInterval) * time.Second) fullSyncTicker := time.NewTicker(time.Duration(config.GetConfig().ElasticsearchFullSyncInterval) * time.Second)
log.Debugf("ELASTIC - started sync timers. Refresh: %d sec. Full: %d sec.", config.GetConfig().ElasticsearchSyncInterval, config.GetConfig().ElasticsearchFullSyncInterval)
for { for {
select { select {
case <-ticker.C: case <-ticker.C: