Close the database when Flamenco shuts down

This prevents SQLite journal files from lingering around.
This commit is contained in:
Sybren A. Stüvel 2023-02-07 15:05:44 +01:00
parent 34f0a6e676
commit aa1c6b8ff3
2 changed files with 10 additions and 0 deletions

View File

@ -137,6 +137,7 @@ func runFlamencoManager() bool {
// Construct the services.
persist := openDB(*configService)
defer persist.Close()
// Disabled for now. `VACUUM` locks the database, which means that other
// queries can fail with a "database is locked (5) (SQLITE_BUSY)" error. This

View File

@ -149,3 +149,12 @@ func (db *DB) vacuum() {
log.Error().Err(tx.Error).Msg("error vacuuming database")
}
}
// Close closes the connection to the database.
func (db *DB) Close() error {
sqldb, err := db.gormDB.DB()
if err != nil {
return err
}
return sqldb.Close()
}