ai_qc/run_api_server.py
nickviljoen b7b7f57b35 Add production deployment migration guide and configuration files
Added comprehensive migration documentation and configuration files for restructuring the application to split frontend/backend:

New Documentation:
- MIGRATION_GUIDE.md: Complete step-by-step migration instructions
- MIGRATION_SUMMARY.md: Quick reference guide for deployment
- MIGRATION_CHECKLIST.md: Printable checklist for migration day
- DEPLOYMENT_RESTRUCTURE.md: Architecture overview and benefits

New Configuration Files:
- run_api_server.py: Production WSGI server wrapper using Waitress
- ai_qc.service: Systemd service configuration for backend
- apache_config.conf: Apache virtual host configuration template

Updated Files:
- requirements.txt: Added waitress>=2.1.2 for production WSGI server
- README.md: Added deployment documentation section

Migration Overview:
- Split current monolithic structure into separate frontend/backend
- Move backend to /opt/ai_qc/ (following server standards)
- Keep frontend in /var/www/html/ai_qc/ (single index.html)
- Use Apache reverse proxy to connect frontend to backend API
- Implement systemd service for reliable backend process management

Benefits:
- Improved security (backend code not in web root)
- Better separation of concerns
- Follows industry best practices
- Matches existing server app patterns (/opt/veo3, /opt/voice2text)
- Easier independent updates of frontend/backend

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-06 11:45:31 +02:00

39 lines
1.1 KiB
Python
Executable file

#!/usr/bin/env python3
"""
Production server wrapper for Visual AI QC
Runs the Flask application using Waitress WSGI server
"""
import argparse
import sys
import os
from waitress import serve
# Add current directory to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
# Import the Flask app
from api_server import app
def main():
parser = argparse.ArgumentParser(description='Run Visual AI QC API Server')
parser.add_argument('--host', default='localhost', help='Host to bind to')
parser.add_argument('--port', type=int, default=7183, help='Port to bind to')
parser.add_argument('--workers', type=int, default=2, help='Number of worker threads')
args = parser.parse_args()
print(f"Starting Visual AI QC server on {args.host}:{args.port}")
print(f"Worker threads: {args.workers}")
print(f"Working directory: {os.getcwd()}")
# Use Waitress WSGI server (production-ready)
serve(
app,
host=args.host,
port=args.port,
threads=args.workers,
url_scheme='http'
)
if __name__ == '__main__':
main()