76 lines
1.6 KiB
Markdown
76 lines
1.6 KiB
Markdown
# Starting the Python Service
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
cd backend/python_service
|
|
uvicorn main:app --reload --port 8000
|
|
```
|
|
|
|
## Using Virtual Environment (Recommended)
|
|
|
|
If you want to use a virtual environment (recommended for isolation):
|
|
|
|
```bash
|
|
# Create virtual environment
|
|
cd backend/python_service
|
|
python -m venv venv
|
|
|
|
# Activate (Windows)
|
|
venv\Scripts\activate
|
|
|
|
# Activate (macOS/Linux)
|
|
source venv/bin/activate
|
|
|
|
# Install dependencies
|
|
pip install -r requirements.txt
|
|
|
|
# Start service
|
|
uvicorn main:app --reload --port 8000
|
|
```
|
|
|
|
## Verify Service is Running
|
|
|
|
Once started, you should see:
|
|
```
|
|
INFO: Uvicorn running on http://127.0.0.1:8000
|
|
INFO: Application startup complete.
|
|
```
|
|
|
|
Test the health endpoint:
|
|
```bash
|
|
curl http://localhost:8000/health
|
|
```
|
|
|
|
Expected response:
|
|
```json
|
|
{
|
|
"status": "healthy",
|
|
"service": "options-flow-processor"
|
|
}
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### ModuleNotFoundError
|
|
- Make sure you've run: `pip install -r requirements.txt`
|
|
- If using venv, make sure it's activated
|
|
- Check Python version: `python --version` (should be 3.11+)
|
|
|
|
### Port Already in Use
|
|
- Change port: `uvicorn main:app --reload --port 8001`
|
|
- Update `PYTHON_SERVICE_URL` in Node.js `.env` to match
|
|
|
|
### Database Connection Error
|
|
- Check `.env` file has correct database credentials
|
|
- Verify PostgreSQL is running
|
|
- Test connection: `psql -h localhost -U postgres -d institutional_trader`
|
|
|
|
## Next Steps
|
|
|
|
Once the Python service is running:
|
|
1. Start Node.js backend: `cd backend && npm run dev`
|
|
2. Node.js will automatically detect and use Python service
|
|
3. Check logs to confirm: `✅ Using Python service`
|
|
|