feat(gateway): optional .env loading for local dev (app + seed); document in e2e guide
This commit is contained in:
@@ -20,6 +20,8 @@ Session script for validating the gateway against a real KepServer + cluster (wi
|
||||
|
||||
## 1. Seed test data
|
||||
|
||||
Copy `.env.example` to `.env` (gitignored) and fill in the values from the session (OPC endpoint, Mongo/Redis/Postgres/MinIO accesses) — both the app and the seed script read it automatically (add `OPC_SERVER_URL=opc.tcp://HOST:49320`; it is seed-only, so it isn't in the example file). Then:
|
||||
|
||||
```bash
|
||||
python scripts/seed_e2e.py --print-only # inspect first
|
||||
python scripts/seed_e2e.py # seed Mongo + Redis slot v1 + Postgres table
|
||||
|
||||
@@ -7,6 +7,13 @@ from time import time
|
||||
|
||||
from prometheus_client import start_http_server
|
||||
|
||||
try: # optional: local dev reads .env; in-cluster env comes from Helm (no .env file)
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
import ingestor.metrics as metrics
|
||||
from ingestor.config import GatewayConfig
|
||||
from ingestor.gateway_runtime import GatewayRuntime
|
||||
|
||||
@@ -16,4 +16,4 @@ pytest-asyncio>=0.21.0 # Async test support (already in main requirements)
|
||||
|
||||
# Development Tools
|
||||
ipython>=8.12.0 # Enhanced Python shell
|
||||
ipdb>=0.13.13 # IPython debugger
|
||||
ipdb>=0.13.13 # IPython debuggerpython-dotenv>=1.0 # local dev only: app/seed read .env if present (in-cluster env comes from Helm)
|
||||
|
||||
@@ -28,6 +28,13 @@ import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
try: # optional: local dev reads .env; in-cluster env comes from Helm
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
OPC_URL = os.getenv('OPC_SERVER_URL', 'opc.tcp://localhost:49320')
|
||||
|
||||
CONNECTOR = {
|
||||
|
||||
Reference in New Issue
Block a user