Skip to content

Commit d09eee9

Browse files
database fix
1 parent 7700782 commit d09eee9

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

init_db.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
import os
12
from app import app
23
from models import db
34

45
if __name__ == '__main__':
6+
# Ensure the data directory exists
7+
data_dir = '/app/data'
8+
os.makedirs(data_dir, exist_ok=True)
9+
print(f"Ensured data directory exists: {data_dir}")
10+
511
with app.app_context():
612
db.create_all()
713
print("Database initialized successfully!")
14+
15+
# Verify the database file was created
16+
db_path = '/app/data/github_backup.db'
17+
if os.path.exists(db_path):
18+
print(f"Database file created at: {db_path}")
19+
else:
20+
print("Warning: Database file not found after initialization")

start.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
11
#!/bin/bash
2+
set -e
3+
4+
echo "Starting GitHub Backup Service..."
5+
6+
# Ensure required directories exist with proper permissions
7+
mkdir -p /app/data /app/logs /app/backups
8+
chmod 755 /app/data /app/logs /app/backups
9+
10+
echo "Directories created/verified:"
11+
ls -la /app/ | grep -E "(data|logs|backups)"
212

313
# Note: Running as non-root user, so we can't start system cron
414
# Instead, we'll rely on APScheduler for job scheduling
515

616
# Initialize database if it doesn't exist
17+
echo "Initializing database..."
718
python init_db.py
819

20+
if [ $? -eq 0 ]; then
21+
echo "Database initialization completed successfully"
22+
else
23+
echo "Database initialization failed!"
24+
exit 1
25+
fi
26+
27+
# Verify database file exists
28+
if [ -f "/app/data/github_backup.db" ]; then
29+
echo "✅ Database file found: /app/data/github_backup.db"
30+
ls -la /app/data/github_backup.db
31+
else
32+
echo "❌ Database file not found at /app/data/github_backup.db"
33+
echo "Directory contents:"
34+
ls -la /app/data/
35+
fi
36+
937
# Start the Flask application
38+
echo "Starting Gunicorn server..."
1039
exec gunicorn --bind 0.0.0.0:8080 --workers 4 --timeout 120 app:app

0 commit comments

Comments
 (0)