#!/usr/bin/env python """ Start script for running the Lin application with Gunicorn. This is primarily for local development and testing of the Gunicorn configuration. For production, the application is run via the Dockerfile CMD. Usage: python start_gunicorn.py Note: This is for local testing only. The production setup uses Gunicorn directly as specified in the gunicorn.conf.py file. """ import subprocess import sys import os from pathlib import Path def main(): """Start the application using Gunicorn.""" print("Starting Lin application with Gunicorn...") print("Note: This is for local testing. Production uses Docker with Gunicorn directly.") print("-" * 60) # Change to the project root directory project_root = Path(__file__).parent os.chdir(project_root) try: # Run gunicorn with the configuration file - use the correct app path cmd = [ "gunicorn", "--config", str(project_root / "gunicorn.conf.py"), # Use the main gunicorn config "backend.app:create_app()" ] print(f"Running command: {' '.join(cmd)}") print("-" * 60) # Start Gunicorn process = subprocess.Popen(cmd) process.wait() except KeyboardInterrupt: print("\nShutting down Gunicorn server...") sys.exit(0) except Exception as e: print(f"Failed to start Gunicorn: {e}") import traceback traceback.print_exc() sys.exit(1) if __name__ == "__main__": main()