forked from choras-org/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·52 lines (41 loc) · 1.58 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·52 lines (41 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
echo "Start entrypoint script..."
echo "Database:" $DATABASE
# Wait for PostgreSQL to be available
if [ "$DATABASE" = "postgres" ]; then
echo "Waiting for PostgreSQL..."
while ! PGPASSWORD=$POSTGRES_PASSWORD psql -h $BBDD_HOST -U $POSTGRES_USER -d $POSTGRES_DB -c '\q'; do
echo "Waiting for PostgreSQL..."
sleep 0.5
done
echo "PostgreSQL started"
fi
echo "Environment:" $APP_ENV
# If in local environment, set up the database and admin user
if [ "$APP_ENV" = "local" ]; then
echo "Start creating the database"
flask create-db
echo "Done creating the database"
echo "Start checking user-admin"
# flask create-user-admin
echo "Done initializing user-admin"
fi
# Start the Flask app using Gunicorn
if [ "$APP_ENV" = "local" ] || [ "$APP_ENV" = "production" ]; then
echo "Running the Flask app with Gunicorn..."
# gunicorn -c ./gunicorn/gunicorn_config.py "$API_ENTRYPOINT" --env APP_SETTINGS_MODULE=$APP_SETTINGS_MODULE
echo "API_ENTRYPOINT: $API_ENTRYPOINT"
echo "APP_SETTINGS_MODULE: $APP_SETTINGS_MODULE"
echo "SQLALCHEMY_DATABASE_URI: $SQLALCHEMY_DATABASE_URI"
gunicorn -c ./gunicorn/gunicorn_config.py "app:app" --bind 0.0.0.0:5001 &
# Start Celery worker if needed
echo "Starting Celery worker..."
celery -A $CELERY_APP worker --loglevel=info -P eventlet &
# Start Celery Beat if needed
if [ "$APP_ENV" = "local" ]; then
echo "Starting Celery Beat..."
celery -A $CELERY_APP beat --loglevel=info &
fi
# Wait for processes to exit (Flask, Celery, Celery Beat)
wait
fi