fix(db): Datenbank nach data/ verschoben, WAL-Checkpoint + robuster Shutdown
- database.path in config.yaml: meshdd.db → data/meshdd.db - data/.gitkeep: Verzeichnis in Git verankert, *.db-wal/shm gitignored - database.py: PRAGMA wal_checkpoint(FULL) vor db.close() für sauberes Schließen - main.py: Shutdown-Schritte einzeln mit try/except gekapselt; db.close() wird jetzt auch bei Fehlern in vorherigen Schritten ausgeführt Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
261f0dac13
commit
57182c5412
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -15,6 +15,8 @@ config/.env
|
|||
*.db
|
||||
*.sqlite
|
||||
*.sqlite3
|
||||
data/*.db-wal
|
||||
data/*.db-shm
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
|
|
|
|||
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -1,5 +1,15 @@
|
|||
# Changelog
|
||||
|
||||
## [0.08.18] - 2026-02-20
|
||||
|
||||
### Changed
|
||||
- **Datenbankdatei nach `data/` verschoben**: `database.path` in `config.yaml` ist jetzt
|
||||
`data/meshdd.db`; WAL/SHM-Dateien in `data/` sind gitignored.
|
||||
- **Sauberes DB-Close**: `database.py` führt vor dem Schließen `PRAGMA wal_checkpoint(FULL)`
|
||||
durch, damit keine Daten im WAL-Journal verbleiben.
|
||||
- **Robusterer Shutdown** in `main.py`: Jeder Shutdown-Schritt (NINA, Bot, WebSocket, Web)
|
||||
ist einzeln mit try/except gekapselt – `db.close()` wird jetzt immer ausgeführt.
|
||||
|
||||
## [0.08.17] - 2026-02-20
|
||||
|
||||
### Changed
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ web:
|
|||
online_threshold: 900
|
||||
|
||||
database:
|
||||
path: "meshdd.db"
|
||||
path: "data/meshdd.db"
|
||||
|
||||
auth:
|
||||
session_max_age: 86400
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
version: "0.08.17"
|
||||
version: "0.08.18"
|
||||
|
||||
bot:
|
||||
name: "MeshDD-Bot"
|
||||
|
|
@ -14,7 +14,7 @@ web:
|
|||
online_threshold: 900
|
||||
|
||||
database:
|
||||
path: "meshdd.db"
|
||||
path: "data/meshdd.db"
|
||||
|
||||
auth:
|
||||
session_max_age: 86400
|
||||
|
|
|
|||
0
data/.gitkeep
Normal file
0
data/.gitkeep
Normal file
20
main.py
20
main.py
|
|
@ -71,10 +71,22 @@ async def main():
|
|||
await stop_event.wait()
|
||||
finally:
|
||||
logger.info("Shutting down...")
|
||||
await nina.stop()
|
||||
bot.disconnect()
|
||||
await ws_manager.close_all()
|
||||
await runner.cleanup()
|
||||
try:
|
||||
await nina.stop()
|
||||
except Exception:
|
||||
logger.exception("Error stopping NINA")
|
||||
try:
|
||||
bot.disconnect()
|
||||
except Exception:
|
||||
logger.exception("Error disconnecting bot")
|
||||
try:
|
||||
await ws_manager.close_all()
|
||||
except Exception:
|
||||
logger.exception("Error closing WebSocket connections")
|
||||
try:
|
||||
await runner.cleanup()
|
||||
except Exception:
|
||||
logger.exception("Error cleaning up web runner")
|
||||
await db.close()
|
||||
logger.info("Shutdown complete")
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,14 @@ class Database:
|
|||
|
||||
async def close(self):
|
||||
if self.db:
|
||||
try:
|
||||
await self.db.execute("PRAGMA wal_checkpoint(FULL)")
|
||||
await self.db.commit()
|
||||
except Exception:
|
||||
logger.exception("Error during WAL checkpoint on close")
|
||||
await self.db.close()
|
||||
self.db = None
|
||||
logger.info("Database closed")
|
||||
|
||||
async def _create_tables(self):
|
||||
await self.db.executescript("""
|
||||
|
|
|
|||
Loading…
Reference in a new issue