SIDEL_ScriptsManager/scripts/run_app.py

54 lines
1.7 KiB
Python
Executable File
Raw Blame History

#!/usr/bin/env python3
"""
Run ScriptsManager application
"""
import sys
import os
from pathlib import Path
# Add the project root to the Python path
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root))
from app.app import create_app, register_routes
def run_app():
"""Run the Flask application"""
app = create_app()
# Register all routes and get socketio instance
socketio = register_routes(app)
# Get port from environment, default to 5002 for production, 5003 for development
port = int(os.environ.get('PORT', 5003 if os.environ.get('DEBUG') == 'true' else 5002))
debug = os.environ.get('DEBUG', 'false').lower() == 'true'
# For development: disable auto-reloader to prevent container restarts when workspaces change
# This avoids the issue where script execution causes Flask to restart
use_reloader = False if debug else False
# Run with SocketIO support
socketio.run(
app,
host="0.0.0.0",
port=port,
debug=debug,
use_reloader=use_reloader
)
if __name__ == "__main__":
port = int(os.environ.get('PORT', 5003 if os.environ.get('DEBUG') == 'true' else 5002))
print("Starting ScriptsManager...")
print(f"🚀 Application will be available at: http://localhost:{port}")
if os.environ.get('DEBUG') == 'true':
print("<EFBFBD> DEVELOPMENT MODE - Auto-reloader disabled for container stability")
print(" Manual restart required for code changes")
else:
print("🏭 PRODUCTION MODE")
print("Press Ctrl+C to stop the server")
print("-" * 50)
run_app()