| 24 | |
| 25 | |
| 26 | def main(): |
| 27 | parser = argparse.ArgumentParser( |
| 28 | description="Start the Mirix REST API server", |
| 29 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 30 | ) |
| 31 | |
| 32 | parser.add_argument( |
| 33 | "--host", |
| 34 | default="0.0.0.0", |
| 35 | help="Host to bind to (default: 0.0.0.0)", |
| 36 | ) |
| 37 | |
| 38 | parser.add_argument( |
| 39 | "--port", |
| 40 | type=int, |
| 41 | default=8531, |
| 42 | help="Port to bind to (default: 8531)", |
| 43 | ) |
| 44 | |
| 45 | parser.add_argument( |
| 46 | "--reload", |
| 47 | action="store_true", |
| 48 | help="Enable auto-reload for development", |
| 49 | ) |
| 50 | |
| 51 | parser.add_argument( |
| 52 | "--workers", |
| 53 | type=int, |
| 54 | default=1, |
| 55 | help="Number of worker processes (default: 1)", |
| 56 | ) |
| 57 | |
| 58 | parser.add_argument( |
| 59 | "--log-level", |
| 60 | default="info", |
| 61 | choices=["critical", "error", "warning", "info", "debug", "trace"], |
| 62 | help="Log level (default: info)", |
| 63 | ) |
| 64 | |
| 65 | parser.add_argument( |
| 66 | "--production", |
| 67 | action="store_true", |
| 68 | help="Run in production mode with multiple workers (requires gunicorn)", |
| 69 | ) |
| 70 | |
| 71 | args = parser.parse_args() |
| 72 | |
| 73 | # Check if running in production mode |
| 74 | if args.production: |
| 75 | try: |
| 76 | import gunicorn.app.base |
| 77 | except ImportError: |
| 78 | print("Error: gunicorn is required for production mode") |
| 79 | print("Install it with: pip install gunicorn") |
| 80 | sys.exit(1) |
| 81 | |
| 82 | print("Starting Mirix server in PRODUCTION mode...") |
| 83 | print(f" Host: {args.host}") |