Browse Source

Merge branch 'development' into development

visuddhinanda 9 months ago
parent
commit
ad6967c67e

+ 10 - 0
ai-translate/ai_translate/__init__.py

@@ -1,6 +1,9 @@
 import logging
 import tomllib
 import json
+import os
+import sys
+
 import pika
 from redis.cluster import RedisCluster
 from types import SimpleNamespace
@@ -10,6 +13,13 @@ from .worker import handle_message
 logger = logging.getLogger(__name__)
 
 
+def is_stopped():
+    f = ".stop"
+    logger.warning("file %s exists, will be exit", f)
+    if os.path.exists(f):
+        sys.exit(0)
+
+
 def open_redis_cluster(config):
     cli = RedisCluster(host=config['host'], port=config['port'])
     logger.debug("%s", cli.get_nodes())

+ 2 - 2
ai-translate/ai_translate/__main__.py

@@ -3,7 +3,7 @@ import argparse
 import sys
 import os
 
-from . import launch
+from . import launch, is_stopped
 
 logger = logging.getLogger(__name__)
 
@@ -31,7 +31,7 @@ def main():
     else:
         logging.basicConfig(
             level=logging.DEBUG if args.debug else logging.INFO, format='%(levelname)-5s %(asctime)s(%(module)s): %(message)s')
-
+    is_stopped()
     try:
         launch(args.name, args.queue, args.config)
     except KeyboardInterrupt:

+ 1 - 1
ai-translate/pyproject.toml

@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
 [project]
 name = "ai_translate"
 version = "2025.6.11"
-requires-python = ">= 3.11"
+requires-python = ">= 3.13"
 description = "An OpenAI consumer process"
 readme = "README.md"
 license = "MIT"

+ 2 - 5
dashboard-v4/documents/development/postgresql/README.md

@@ -9,14 +9,11 @@
 - 导出数据库
 
   ```bash
-  pg_dump -O -s -h 127.0.0.1 -p 5432 -U www demo > demo-schema-20221009.sql
-  pg_dump -Fc -O -a -h 127.0.0.1 -p 5432 -U www demo | gzip -9 > demo-data-20221009.dump.gz
+  pg_dump -Fc -O -a -Z 9 --dbname postgresql://USER:PASSWORD@HOST:PORT/DB_NAME -T migrations -f DB_NAME-data-$(date +"%Y%m%d%H%M%S").dump.gz
   ```
 
 - 导入数据库
 
   ```bash
-  psql -h 127.0.0.1 -p 5432 -U www demo < demo-schema-20221009.sql
-  gunzip demo-20221009.dump.gz
-  pg_restore -Fc -h 127.0.0.1 -p 5432 -U www -d demo < demo-20221009.dump
+  pg_restore -h HOST -p PORT -U USER -d DB_NAME -1 FILE
   ```