mirror of
https://github.com/dataelement/bisheng.git
synced 2026-10-28 03:40:25 +08:00
feat: add celery worker container
This commit is contained in:
@@ -1,4 +1,15 @@
|
||||
nohup uvicorn bisheng.main:app --host 0.0.0.0 --port 7860 --no-access-log --workers 8 &
|
||||
#!/bin/bash
|
||||
|
||||
# -c 是指定celery的并发数
|
||||
celery -A bisheng.worker.main worker -l info -c 16
|
||||
start_mode=${1:-api}
|
||||
|
||||
if [ "$start_mode" == "api" ]; then
|
||||
echo "Starting API server..."
|
||||
uvicorn bisheng.main:app --host 0.0.0.0 --port 7860 --no-access-log --workers 8
|
||||
elif [ "$start_mode" == "celery" ]; then
|
||||
echo "Starting Celery worker..."
|
||||
# -c 是指定celery的并发数,线程数
|
||||
celery -A bisheng.worker.main worker -l info -c 100 -P threads
|
||||
else
|
||||
echo "Invalid start mode. Use 'api' or 'celery'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -75,7 +75,45 @@ services:
|
||||
- ${DOCKER_VOLUME_DIRECTORY:-.}/data/bisheng:/app/data
|
||||
security_opt:
|
||||
- seccomp:unconfined
|
||||
command: sh entrypoint.sh # --workers 表示使用几个进程,提高并发度
|
||||
command: sh entrypoint.sh api # 启动api服务
|
||||
restart: on-failure
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:7860/health"]
|
||||
start_period: 30s
|
||||
interval: 90s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
office:
|
||||
condition: service_started
|
||||
|
||||
backend_worker:
|
||||
container_name: bisheng-backend-worker
|
||||
image: dataelement/bisheng-backend:v1.3.0
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
BS_MILVUS_CONNECTION_ARGS: '{"host":"milvus","port":"19530","user":"","password":"","secure":false}'
|
||||
BS_MILVUS_IS_PARTITION: 'true'
|
||||
BS_MILVUS_PARTITION_SUFFIX: '1'
|
||||
BS_ELASTICSEARCH_URL: 'http://elasticsearch:9200'
|
||||
BS_ELASTICSEARCH_SSL_VERIFY: '{}' # 可根据自己部署的密码进行配置 '{"basic_auth": ("elastic", "elastic")}'
|
||||
BS_MINIO_SCHEMA: 'false'
|
||||
BS_MINIO_CERT_CHECK: 'false'
|
||||
BS_MINIO_ENDPOINT: 'minio:9000'
|
||||
BS_MINIO_SHAREPOIN: 'minio:9000'
|
||||
BS_MINIO_ACCESS_KEY: 'minioadmin'
|
||||
BS_MINIO_SECRET_KEY: 'minioadmin'
|
||||
volumes:
|
||||
- ${DOCKER_VOLUME_DIRECTORY:-.}/bisheng/config/config.yaml:/app/bisheng/config.yaml
|
||||
- ${DOCKER_VOLUME_DIRECTORY:-.}/bisheng/entrypoint.sh:/app/entrypoint.sh
|
||||
- ${DOCKER_VOLUME_DIRECTORY:-.}/data/bisheng:/app/data
|
||||
security_opt:
|
||||
- seccomp:unconfined
|
||||
command: sh entrypoint.sh worker # 启动celery的异步worker服务,用来处理一些耗时的任务
|
||||
restart: on-failure
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:7860/health"]
|
||||
|
||||
@@ -7,3 +7,7 @@ result_serializer = 'json'
|
||||
accept_content = ['json']
|
||||
timezone = 'Asia/Shanghai'
|
||||
enable_utc = False
|
||||
task_routes = {
|
||||
'bisheng.worker.workflow.*': {'queue': 'celery_workflow'},
|
||||
'bisheng.worker.knowledge.*': {'queue': 'celery_knowledge'},
|
||||
}
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
nohup uvicorn bisheng.main:app --host 0.0.0.0 --port 7860 --no-access-log --workers 8 &
|
||||
#!/bin/bash
|
||||
|
||||
# -c 是指定celery的并发数,线程数
|
||||
celery -A bisheng.worker.main worker -l info -c 100 -P threads
|
||||
start_mode=${1:-api}
|
||||
|
||||
if [ "$start_mode" == "api" ]; then
|
||||
echo "Starting API server..."
|
||||
uvicorn bisheng.main:app --host 0.0.0.0 --port 7860 --no-access-log --workers 8
|
||||
elif [ "$start_mode" == "celery" ]; then
|
||||
echo "Starting Celery worker..."
|
||||
# -c 是指定celery的并发数,线程数
|
||||
celery -A bisheng.worker.main worker -l info -c 100 -P threads
|
||||
else
|
||||
echo "Invalid start mode. Use 'api' or 'celery'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user