1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Improve health check endpoint to test database connection

This commit is contained in:
Frédéric Guillot 2021-02-19 18:47:50 -08:00 committed by fguillot
parent c2571f9f47
commit e3c28a6c96
4 changed files with 29 additions and 14 deletions

View file

@ -126,17 +126,21 @@ func Parse() {
config.Opts.DatabaseMaxConns(),
)
if err != nil {
logger.Fatal("Unable to connect to the database: %v", err)
logger.Fatal("Unable to initialize database connection pool: %v", err)
}
defer db.Close()
store := storage.NewStorage(db)
if err := store.Ping(); err != nil {
logger.Fatal("Unable to connect to the database: %v", err)
}
if flagMigrate {
database.Migrate(db)
return
}
store := storage.NewStorage(db)
if flagResetFeedErrors {
store.ResetFeedErrors()
return