Severian commited on
Commit
9b546e3
·
verified ·
1 Parent(s): 4f3395e

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +17 -3
entrypoint.sh CHANGED
@@ -1,11 +1,16 @@
 
 
1
  set -e
2
 
 
 
3
  if [[ "${MIGRATION_ENABLED}" == "true" ]]; then
4
  echo "Running migrations"
5
- cd /app/api && poetry run flask db upgrade
6
  fi
7
 
8
  if [[ "${MODE}" == "worker" ]]; then
 
9
  if [ "${CELERY_AUTO_SCALE,,}" = "true" ]; then
10
  AVAILABLE_CORES=$(nproc)
11
  MAX_WORKERS=${CELERY_MAX_WORKERS:-$AVAILABLE_CORES}
@@ -15,11 +20,20 @@ if [[ "${MODE}" == "worker" ]]; then
15
  CONCURRENCY_OPTION="-c ${CELERY_WORKER_AMOUNT:-1}"
16
  fi
17
 
18
- exec poetry run celery -A app.celery worker -P ${CELERY_WORKER_CLASS:-gevent} $CONCURRENCY_OPTION --loglevel ${LOG_LEVEL} \
 
 
 
19
  -Q ${CELERY_QUEUES:-dataset,mail,ops_trace,app_deletion}
 
 
 
20
  else
21
  if [[ "${DEBUG}" == "true" ]]; then
22
- exec poetry run flask run --host=${DIFY_BIND_ADDRESS:-0.0.0.0} --port=7860 --debug
 
 
 
23
  else
24
  exec poetry run gunicorn \
25
  --bind "0.0.0.0:7860" \
 
1
+ #!/bin/bash
2
+
3
  set -e
4
 
5
+ cd /app/api
6
+
7
  if [[ "${MIGRATION_ENABLED}" == "true" ]]; then
8
  echo "Running migrations"
9
+ poetry run flask db upgrade
10
  fi
11
 
12
  if [[ "${MODE}" == "worker" ]]; then
13
+ # Get the number of available CPU cores
14
  if [ "${CELERY_AUTO_SCALE,,}" = "true" ]; then
15
  AVAILABLE_CORES=$(nproc)
16
  MAX_WORKERS=${CELERY_MAX_WORKERS:-$AVAILABLE_CORES}
 
20
  CONCURRENCY_OPTION="-c ${CELERY_WORKER_AMOUNT:-1}"
21
  fi
22
 
23
+ exec poetry run celery -A app.celery worker \
24
+ -P ${CELERY_WORKER_CLASS:-gevent} \
25
+ $CONCURRENCY_OPTION \
26
+ --loglevel ${LOG_LEVEL} \
27
  -Q ${CELERY_QUEUES:-dataset,mail,ops_trace,app_deletion}
28
+
29
+ elif [[ "${MODE}" == "beat" ]]; then
30
+ exec poetry run celery -A app.celery beat --loglevel ${LOG_LEVEL}
31
  else
32
  if [[ "${DEBUG}" == "true" ]]; then
33
+ exec poetry run flask run \
34
+ --host=${DIFY_BIND_ADDRESS:-0.0.0.0} \
35
+ --port=7860 \
36
+ --debug
37
  else
38
  exec poetry run gunicorn \
39
  --bind "0.0.0.0:7860" \