TRA-4501 Don't panic in case of a Basenine connection error and try to reconnect with 3 seconds intervals (#1012)

* Don't panic in case of a Basenine connection error and try to reconnect with 3 seconds intervals

* More improvements
This commit is contained in:
M. Mert Yıldıran
2022-04-18 01:00:43 -07:00
committed by GitHub
parent d7fcf273c0
commit c5006e5f57
4 changed files with 49 additions and 29 deletions

View File

@@ -211,11 +211,15 @@ func syncEntriesImpl(token string, model string, envPrefix string, uploadInterva
logger.Log.Infof("Getting entries from the database")
BasenineReconnect:
var connection *basenine.Connection
var err error
connection, err = basenine.NewConnection(shared.BasenineHost, shared.BaseninePort)
if err != nil {
panic(err)
logger.Log.Errorf("Can't establish a new connection to Basenine server: %v", err)
connection.Close()
time.Sleep(shared.BasenineReconnectInterval * time.Second)
goto BasenineReconnect
}
data := make(chan []byte)
@@ -324,7 +328,10 @@ func syncEntriesImpl(token string, model string, envPrefix string, uploadInterva
wg.Add(2)
if err = connection.Query(query, data, meta); err != nil {
logger.Log.Panicf("Query mode call failed: %v", err)
logger.Log.Errorf("Query mode call failed: %v", err)
connection.Close()
time.Sleep(shared.BasenineReconnectInterval * time.Second)
goto BasenineReconnect
}
wg.Wait()