Make manage.py use the service's database
manage.py only found the database via BACKUP_DASH_DB, which is set in the systemd unit and not in an admin's shell, so it silently created a new backup-dashboard.db in the current directory. API keys created there were never seen by the service. - Settings now come from /etc/backup-dashboard/backup-dashboard.env, which both the systemd unit (EnvironmentFile=) and manage.py read; real environment variables still take precedence - manage.py prints the database it uses and refuses to create a new one unless --create is passed; --db overrides the path Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -6,8 +6,8 @@ After=network.target
|
||||
User=backupdash
|
||||
Group=backupdash
|
||||
WorkingDirectory=/opt/backup-dashboard/backend
|
||||
Environment=BACKUP_DASH_DB=/var/lib/backup-dashboard/backup-dashboard.db
|
||||
Environment=BACKUP_DASH_RETENTION_DAYS=90
|
||||
# Settings live in this file so manage.py reads exactly the same ones (see deploy/backup-dashboard.env)
|
||||
EnvironmentFile=/etc/backup-dashboard/backup-dashboard.env
|
||||
# Bound to localhost: only nginx can reach it, so nginx's auth can't be bypassed from outside.
|
||||
# One worker is plenty at this scale and keeps SQLite writes simple.
|
||||
ExecStart=/opt/backup-dashboard/venv/bin/uvicorn --factory app.main:create_app --host 127.0.0.1 --port 8000 --proxy-headers
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# Install as /etc/backup-dashboard/backup-dashboard.env
|
||||
# Read by both the API service and manage.py, so they always use the same database.
|
||||
BACKUP_DASH_DB=/var/lib/backup-dashboard/backup-dashboard.db
|
||||
BACKUP_DASH_RETENTION_DAYS=90
|
||||
Reference in New Issue
Block a user