mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-12-22 17:14:22 +00:00
Improve server shutdown process
This commit is contained in:
@@ -107,6 +107,12 @@ func Open(config *Config) (*sqliteDB, error) {
|
||||
func (db *sqliteDB) Close() error {
|
||||
if db.DB != nil {
|
||||
log.Println("Closing database connection")
|
||||
|
||||
// Checkpoint WAL to merge changes back to main database file
|
||||
if _, err := db.DB.Exec("PRAGMA wal_checkpoint(TRUNCATE)"); err != nil {
|
||||
log.Printf("Warning: Failed to checkpoint WAL: %v", err)
|
||||
}
|
||||
|
||||
return db.DB.Close()
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -114,11 +114,6 @@ func (im *instanceManager) Shutdown() {
|
||||
}
|
||||
wg.Wait()
|
||||
fmt.Println("All instances stopped.")
|
||||
|
||||
// 4. Close database connection
|
||||
if err := im.db.Close(); err != nil {
|
||||
log.Printf("Error closing database: %v\n", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user