-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change pattern of dockerfile to model cloud
- Loading branch information
1 parent
15a9fde
commit dfd3fd6
Showing
2 changed files
with
150 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,72 @@ | ||
#!/bin/bash | ||
|
||
echo "Running collectstatic" | ||
python manage.py collectstatic --noinput | ||
export GUNICORN_APP=${GUNICORN_APP:-"apip.wsgi"} | ||
# export CELERY_APP=${CELERY_APP:-"apiphantom"} | ||
export GUNICORN_CONF=${GUNICORN_CONF:-"${PROJECT_PATH}/gunicorn.conf.py"} | ||
export LOG_LEVEL=${LOG_LEVEL:-"INFO"} | ||
export HEALTHCHECK_TIMEOUT=${HEALTHCHECK_TIMEOUT:-"10"} | ||
|
||
echo "Starting servers" | ||
gunicorn apip.wsgi -c gunicorn.conf.py | ||
do_gosu(){ | ||
user="$1" | ||
shift 1 | ||
|
||
is_exec="false" | ||
if [ "$1" = "exec" ]; then | ||
is_exec="true" | ||
shift 1 | ||
fi | ||
|
||
if [ "$(id -u)" = "0" ]; then | ||
if [ "${is_exec}" = "true" ]; then | ||
exec gosu "${user}" "$@" | ||
else | ||
gosu "${user}" "$@" | ||
return "$?" | ||
fi | ||
else | ||
if [ "${is_exec}" = "true" ]; then | ||
exec "$@" | ||
else | ||
eval '"$@"' | ||
return "$?" | ||
fi | ||
fi | ||
} | ||
|
||
|
||
if [[ "start" == "$1" ]]; then | ||
do_gosu "${PROJECT_USER}:${PROJECT_GROUP}" python manage.py collectstatic --noinput | ||
do_gosu "${PROJECT_USER}:${PROJECT_GROUP}" exec gunicorn "${GUNICORN_APP}" \ | ||
--name="${APPLICATION_NAME}" \ | ||
--chdir="${PROJECT_PATH}" \ | ||
--bind=0.0.0.0:8000 \ | ||
-c "${GUNICORN_CONF}" | ||
|
||
# elif [[ "celery-worker" == "$1" ]]; then | ||
# celery_queue="celery" | ||
# if [ "${2}" ] ; then | ||
# celery_queue="${2}" | ||
# fi | ||
# do_gosu "${PROJECT_USER}:${PROJECT_GROUP}" exec celery \ | ||
# -A "${CELERY_APP}" --workdir="${PROJECT_PATH}" worker \ | ||
# -Q "${celery_queue}" \ | ||
# -O fair \ | ||
# -l "${LOG_LEVEL}" \ | ||
# --autoscale=${CELERY_MAX_WORKERS},1 | ||
# elif [[ "healthcheck-celery-worker" == "$1" ]]; then | ||
# celery_queue="celery" | ||
# if [ "${2}" ] ; then | ||
# celery_queue="${2}" | ||
# fi | ||
# HEALTHCHECK_OUT=$( | ||
# do_gosu "${PROJECT_USER}:${PROJECT_GROUP}" celery -A "${CELERY_APP}" \ | ||
# inspect ping \ | ||
# -d "${celery_queue}@${HOSTNAME}" \ | ||
# --timeout "${HEALTHCHECK_TIMEOUT}" 2>&1 | ||
# ) | ||
# echo "${HEALTHCHECK_OUT}" | ||
# grep -F -qs "${celery_queue}@${HOSTNAME}: OK" <<< "${HEALTHCHECK_OUT}" || exit 1 | ||
# exit 0 | ||
fi | ||
|
||
exec "$@" |