File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
12from app import app
23from models import db
34
45if __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" )
Original file line number Diff line number Diff line change 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..."
718python 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..."
1039exec gunicorn --bind 0.0.0.0:8080 --workers 4 --timeout 120 app:app
You can’t perform that action at this time.
0 commit comments