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
|
*.db
|
||||||
*.sqlite
|
*.sqlite
|
||||||
*.sqlite3
|
*.sqlite3
|
||||||
|
data/*.db-wal
|
||||||
|
data/*.db-shm
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
*.swp
|
*.swp
|
||||||
|
|
|
||||||
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -1,5 +1,15 @@
|
||||||
# Changelog
|
# 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
|
## [0.08.17] - 2026-02-20
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ web:
|
||||||
online_threshold: 900
|
online_threshold: 900
|
||||||
|
|
||||||
database:
|
database:
|
||||||
path: "meshdd.db"
|
path: "data/meshdd.db"
|
||||||
|
|
||||||
auth:
|
auth:
|
||||||
session_max_age: 86400
|
session_max_age: 86400
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
version: "0.08.17"
|
version: "0.08.18"
|
||||||
|
|
||||||
bot:
|
bot:
|
||||||
name: "MeshDD-Bot"
|
name: "MeshDD-Bot"
|
||||||
|
|
@ -14,7 +14,7 @@ web:
|
||||||
online_threshold: 900
|
online_threshold: 900
|
||||||
|
|
||||||
database:
|
database:
|
||||||
path: "meshdd.db"
|
path: "data/meshdd.db"
|
||||||
|
|
||||||
auth:
|
auth:
|
||||||
session_max_age: 86400
|
session_max_age: 86400
|
||||||
|
|
|
||||||
0
data/.gitkeep
Normal file
0
data/.gitkeep
Normal file
12
main.py
12
main.py
|
|
@ -71,10 +71,22 @@ async def main():
|
||||||
await stop_event.wait()
|
await stop_event.wait()
|
||||||
finally:
|
finally:
|
||||||
logger.info("Shutting down...")
|
logger.info("Shutting down...")
|
||||||
|
try:
|
||||||
await nina.stop()
|
await nina.stop()
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Error stopping NINA")
|
||||||
|
try:
|
||||||
bot.disconnect()
|
bot.disconnect()
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Error disconnecting bot")
|
||||||
|
try:
|
||||||
await ws_manager.close_all()
|
await ws_manager.close_all()
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Error closing WebSocket connections")
|
||||||
|
try:
|
||||||
await runner.cleanup()
|
await runner.cleanup()
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Error cleaning up web runner")
|
||||||
await db.close()
|
await db.close()
|
||||||
logger.info("Shutdown complete")
|
logger.info("Shutdown complete")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,14 @@ class Database:
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
if self.db:
|
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()
|
await self.db.close()
|
||||||
|
self.db = None
|
||||||
|
logger.info("Database closed")
|
||||||
|
|
||||||
async def _create_tables(self):
|
async def _create_tables(self):
|
||||||
await self.db.executescript("""
|
await self.db.executescript("""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue