Commit 778c299a8929b41cdbbf1665d9f7f8020e6f7434
1 parent
b423bf43
测试环境redis配置
Showing
8 changed files
with
16 additions
and
31 deletions
Show diff stats
| ... | ... | @@ -58,9 +58,10 @@ TEI_MAX_CLIENT_BATCH_SIZE=8 |
| 58 | 58 | BACKEND_PROXY_URL=http://127.0.0.1:6002 |
| 59 | 59 | |
| 60 | 60 | # ===== test env connectivity overrides (2026-04-12) ===== |
| 61 | -REDIS_HOST=127.0.0.1 | |
| 61 | +REDIS_HOST=localhost | |
| 62 | 62 | REDIS_PORT=6479 |
| 63 | 63 | REDIS_PASSWORD=BMfv5aI31kgHWtlx |
| 64 | +REDIS_DB=6 | |
| 64 | 65 | DB_HOST=120.79.247.228 |
| 65 | 66 | DB_PORT=3316 |
| 66 | 67 | DB_DATABASE=saas | ... | ... |
.env.example
| ... | ... | @@ -12,6 +12,8 @@ ES_PASSWORD= |
| 12 | 12 | # Redis (生产默认 10.200.16.14:6479,密码见 docs/QUICKSTART.md §1.6) |
| 13 | 13 | REDIS_HOST=10.200.16.14 |
| 14 | 14 | REDIS_PORT=6479 |
| 15 | +# 逻辑库编号(与 config.yaml infrastructure.redis.snapshot_db 一致;测试可与生产共用实例时用不同 db 隔离) | |
| 16 | +REDIS_DB=0 | |
| 15 | 17 | REDIS_PASSWORD= |
| 16 | 18 | |
| 17 | 19 | # DeepL Translation API | ... | ... |
config/environments/test.yaml
| 1 | -query_config: | |
| 2 | - enable_text_embedding: true | |
| 3 | - text_embedding_field: title_embedding | |
| 4 | - zh_to_en_model: deepl | |
| 5 | - en_to_zh_model: deepl | |
| 6 | - default_translation_model: deepl | |
| 7 | - zh_to_en_model__source_not_in_index: deepl | |
| 8 | - en_to_zh_model__source_not_in_index: deepl | |
| 9 | - default_translation_model__source_not_in_index: deepl | |
| 10 | - | |
| 1 | +# 仅覆盖与主干不同的测试环境项;query / translation / redis 等与 config.yaml 一致处不写在此文件中。 | |
| 11 | 2 | infrastructure: |
| 12 | 3 | elasticsearch: |
| 13 | 4 | host: http://127.0.0.1:19200 |
| ... | ... | @@ -28,24 +19,6 @@ services: |
| 28 | 19 | model_id: BAAI/bge-m3 |
| 29 | 20 | timeout_sec: 60 |
| 30 | 21 | max_client_batch_size: 8 |
| 31 | - translation: | |
| 32 | - service_url: http://127.0.0.1:6006 | |
| 33 | - default_model: deepl | |
| 34 | - default_scene: general | |
| 35 | - timeout_sec: 10.0 | |
| 36 | - capabilities: | |
| 37 | - qwen-mt: | |
| 38 | - enabled: false | |
| 39 | - llm: | |
| 40 | - enabled: false | |
| 41 | - deepl: | |
| 42 | - enabled: true | |
| 43 | - nllb-200-distilled-600m: | |
| 44 | - enabled: false | |
| 45 | - opus-mt-zh-en: | |
| 46 | - enabled: false | |
| 47 | - opus-mt-en-zh: | |
| 48 | - enabled: false | |
| 49 | 22 | |
| 50 | 23 | fine_rank: |
| 51 | 24 | enabled: false | ... | ... |
config/loader.py
| ... | ... | @@ -822,6 +822,13 @@ class AppConfigLoader: |
| 822 | 822 | |
| 823 | 823 | def _build_infrastructure_config(self, environment: str) -> InfrastructureConfig: |
| 824 | 824 | del environment |
| 825 | + _redis_db_raw = os.getenv("REDIS_DB") or os.getenv("REDIS_SNAPSHOT_DB") | |
| 826 | + _redis_db = 0 | |
| 827 | + if _redis_db_raw is not None and str(_redis_db_raw).strip() != "": | |
| 828 | + try: | |
| 829 | + _redis_db = int(str(_redis_db_raw).strip()) | |
| 830 | + except ValueError: | |
| 831 | + _redis_db = 0 | |
| 825 | 832 | return InfrastructureConfig( |
| 826 | 833 | elasticsearch=ElasticsearchSettings( |
| 827 | 834 | host=os.getenv("ES_HOST", "http://localhost:9200"), |
| ... | ... | @@ -831,7 +838,7 @@ class AppConfigLoader: |
| 831 | 838 | redis=RedisSettings( |
| 832 | 839 | host=os.getenv("REDIS_HOST", "localhost"), |
| 833 | 840 | port=int(os.getenv("REDIS_PORT", 6479)), |
| 834 | - snapshot_db=int(os.getenv("REDIS_SNAPSHOT_DB", 0)), | |
| 841 | + snapshot_db=_redis_db, | |
| 835 | 842 | password=os.getenv("REDIS_PASSWORD"), |
| 836 | 843 | socket_timeout=int(os.getenv("REDIS_SOCKET_TIMEOUT", 1)), |
| 837 | 844 | socket_connect_timeout=int(os.getenv("REDIS_SOCKET_CONNECT_TIMEOUT", 1)), | ... | ... |
embeddings/redis_embedding_cache.py
| ... | ... | @@ -53,6 +53,7 @@ class RedisEmbeddingCache: |
| 53 | 53 | client = redis.Redis( |
| 54 | 54 | host=redis_config.host, |
| 55 | 55 | port=redis_config.port, |
| 56 | + db=redis_config.snapshot_db, | |
| 56 | 57 | password=redis_config.password, |
| 57 | 58 | decode_responses=False, |
| 58 | 59 | socket_timeout=redis_config.socket_timeout, | ... | ... |
indexer/product_enrich.py
| ... | ... | @@ -124,6 +124,7 @@ try: |
| 124 | 124 | _anchor_redis = redis.Redis( |
| 125 | 125 | host=_REDIS_CONFIG.host, |
| 126 | 126 | port=_REDIS_CONFIG.port, |
| 127 | + db=_REDIS_CONFIG.snapshot_db, | |
| 127 | 128 | password=_REDIS_CONFIG.password, |
| 128 | 129 | decode_responses=True, |
| 129 | 130 | socket_timeout=_REDIS_CONFIG.socket_timeout, | ... | ... |
models deleted
translation/cache.py