mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-01-04 10:40:23 -06:00
- Clients: add model, routes, and templates
- app/models/client.py
- app/routes/clients.py
- templates/clients/{create,edit,list,view}.html
- docs/CLIENT_MANAGEMENT_README.md
- Database: add enhanced init/verify scripts, migrations, and docs
- docker/{init-database-enhanced.py,start-enhanced.py,verify-database.py}
- docs/ENHANCED_DATABASE_STARTUP.md
- migrations/{add_analytics_column.sql,add_analytics_setting.py,migrate_to_client_model.py}
- Scripts: add version manager and docker network test helpers
- scripts/version-manager.{bat,ps1,py,sh}
- scripts/test-docker-network.{bat,sh}
- docs/VERSION_MANAGEMENT.md
- UI: tweak base stylesheet
- app/static/base.css
- Tests: add client system test
- test_client_system.py
86 lines
2.5 KiB
Python
86 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Enhanced Python startup script for TimeTracker
|
|
This script ensures proper database initialization with enhanced schema verification
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import time
|
|
import subprocess
|
|
import traceback
|
|
|
|
def wait_for_database():
|
|
"""Wait for database to be ready"""
|
|
print("Waiting for database to be ready...")
|
|
time.sleep(5) # Simple wait for now
|
|
|
|
def run_script(script_path, description):
|
|
"""Run a Python script with proper error handling"""
|
|
print(f"Running {description}...")
|
|
try:
|
|
result = subprocess.run(
|
|
[sys.executable, script_path],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True
|
|
)
|
|
print(f"✓ {description} completed successfully")
|
|
if result.stdout:
|
|
print(f"Output: {result.stdout}")
|
|
return True
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"✗ {description} failed with exit code {e.returncode}")
|
|
if e.stdout:
|
|
print(f"stdout: {e.stdout}")
|
|
if e.stderr:
|
|
print(f"stderr: {e.stderr}")
|
|
return False
|
|
except Exception as e:
|
|
print(f"✗ Unexpected error running {description}: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
def display_network_info():
|
|
"""Display network information for debugging"""
|
|
print("=== Network Information ===")
|
|
print(f"Hostname: {os.uname().nodename}")
|
|
print(f"IP Address: {os.popen('hostname -I').read().strip()}")
|
|
print(f"Environment: {os.environ.get('FLASK_APP', 'N/A')}")
|
|
print(f"Working Directory: {os.getcwd()}")
|
|
print("==========================")
|
|
|
|
def main():
|
|
print("=== Starting TimeTracker (Enhanced Mode) ===")
|
|
|
|
# Display network information for debugging
|
|
display_network_info()
|
|
|
|
# Set environment
|
|
os.environ['FLASK_APP'] = 'app'
|
|
os.chdir('/app')
|
|
|
|
# Wait for database
|
|
wait_for_database()
|
|
|
|
# Run enhanced database initialization (handles everything in one script)
|
|
if not run_script('/app/docker/init-database-enhanced.py', 'Enhanced database initialization'):
|
|
print("Enhanced database initialization failed, exiting...")
|
|
sys.exit(1)
|
|
|
|
print("✓ All database initialization completed successfully")
|
|
|
|
print("Starting application...")
|
|
# Start gunicorn
|
|
os.execv('/usr/local/bin/gunicorn', [
|
|
'gunicorn',
|
|
'--bind', '0.0.0.0:8080',
|
|
'--worker-class', 'eventlet',
|
|
'--workers', '1',
|
|
'--timeout', '120',
|
|
'app:create_app()'
|
|
])
|
|
|
|
if __name__ == '__main__':
|
|
main()
|