Run the API server.
()
| 6 | |
| 7 | |
| 8 | def main(): |
| 9 | """Run the API server.""" |
| 10 | try: |
| 11 | from jockey.api.main import app |
| 12 | |
| 13 | host = os.getenv("API_HOST", "0.0.0.0") |
| 14 | port = int(os.getenv("API_PORT", "8000")) |
| 15 | reload = os.getenv("API_RELOAD", "true").lower() == "true" |
| 16 | |
| 17 | print(f"Starting Jockey Deployment API on {host}:{port}") |
| 18 | print(f"Redis host: {os.getenv('DEPLOY_REDIS_HOST', 'localhost')}") |
| 19 | print(f"Redis port: {os.getenv('DEPLOY_REDIS_PORT', '6379')}") |
| 20 | |
| 21 | if reload: |
| 22 | # Use import string for reload mode |
| 23 | uvicorn.run("jockey.api.main:app", host=host, port=port, reload=reload) |
| 24 | else: |
| 25 | uvicorn.run(app, host=host, port=port, reload=reload) |
| 26 | |
| 27 | except ImportError as e: |
| 28 | print(f"Import error: {e}") |
| 29 | print("Make sure you're running this from the correct directory") |
| 30 | return 1 |
| 31 | except Exception as e: |
| 32 | print(f"Error starting API: {e}") |
| 33 | return 1 |
| 34 | |
| 35 | return 0 |
| 36 | |
| 37 | |
| 38 | if __name__ == "__main__": |