加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
docker-entrypoint.sh 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/sh
set -eo pipefail
WORKERS=${WORKERS:-1}
WORKER_CLASS=${WORKER_CLASS:-gevent}
ACCESS_LOG=${ACCESS_LOG:--}
ERROR_LOG=${ERROR_LOG:--}
WORKER_TEMP_DIR=${WORKER_TEMP_DIR:-/dev/shm}
# Check that a .ctfd_secret_key file or SECRET_KEY envvar is set
if [ ! -f .ctfd_secret_key ] && [ -z "$SECRET_KEY" ]; then
if [ $WORKERS -gt 1 ]; then
echo "[ ERROR ] You are configured to use more than 1 worker."
echo "[ ERROR ] To do this, you must define the SECRET_KEY environment variable or create a .ctfd_secret_key file."
echo "[ ERROR ] Exiting..."
exit 1
fi
fi
# Check that the database is available
if [ -n "$DATABASE_URL" ]
then
url=`echo $DATABASE_URL | awk -F[@//] '{print $4}'`
database=`echo $url | awk -F[:] '{print $1}'`
port=`echo $url | awk -F[:] '{print $2}'`
echo "Waiting for $database:$port to be ready"
while ! mysqladmin ping -h "$database" -P "$port" --silent; do
# Show some progress
echo -n '.';
sleep 1;
done
echo "$database is ready"
# Give it another second.
sleep 1;
fi
# Initialize database
python manage.py db upgrade
# Start CTFd
echo "Starting CTFd"
exec gunicorn 'CTFd:create_app()' \
--bind '0.0.0.0:4000' \
--workers $WORKERS \
--worker-tmp-dir "$WORKER_TEMP_DIR" \
--worker-class "$WORKER_CLASS" \
--access-logfile "$ACCESS_LOG" \
--error-logfile "$ERROR_LOG"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化