mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
f656e1bae2
Some checks are pending
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
41 lines
1.2 KiB
Bash
Executable File
41 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
if [[ "${MIGRATION_ENABLED}" == "true" ]]; then
|
|
echo "Running migrations"
|
|
flask upgrade-db
|
|
fi
|
|
|
|
if [[ "${MODE}" == "worker" ]]; then
|
|
|
|
# Get the number of available CPU cores
|
|
if [ "${CELERY_AUTO_SCALE,,}" = "true" ]; then
|
|
# Set MAX_WORKERS to the number of available cores if not specified
|
|
AVAILABLE_CORES=$(nproc)
|
|
MAX_WORKERS=${CELERY_MAX_WORKERS:-$AVAILABLE_CORES}
|
|
MIN_WORKERS=${CELERY_MIN_WORKERS:-1}
|
|
CONCURRENCY_OPTION="--autoscale=${MAX_WORKERS},${MIN_WORKERS}"
|
|
else
|
|
CONCURRENCY_OPTION="-c ${CELERY_WORKER_AMOUNT:-1}"
|
|
fi
|
|
|
|
exec celery -A app.celery worker -P ${CELERY_WORKER_CLASS:-gevent} $CONCURRENCY_OPTION --loglevel INFO \
|
|
-Q ${CELERY_QUEUES:-dataset,generation,mail,ops_trace,app_deletion}
|
|
|
|
elif [[ "${MODE}" == "beat" ]]; then
|
|
exec celery -A app.celery beat --loglevel INFO
|
|
else
|
|
if [[ "${DEBUG}" == "true" ]]; then
|
|
exec flask run --host=${DIFY_BIND_ADDRESS:-0.0.0.0} --port=${DIFY_PORT:-5001} --debug
|
|
else
|
|
exec gunicorn \
|
|
--bind "${DIFY_BIND_ADDRESS:-0.0.0.0}:${DIFY_PORT:-5001}" \
|
|
--workers ${SERVER_WORKER_AMOUNT:-1} \
|
|
--worker-class ${SERVER_WORKER_CLASS:-gevent} \
|
|
--timeout ${GUNICORN_TIMEOUT:-200} \
|
|
--preload \
|
|
app:app
|
|
fi
|
|
fi
|