vishalbhat07/ctfd
0
1#!/bin/bash2set -euo pipefail3 4WORKERS=${WORKERS:-1}5WORKER_CLASS=${WORKER_CLASS:-gevent}6ACCESS_LOG=${ACCESS_LOG:--}7ERROR_LOG=${ERROR_LOG:--}8WORKER_TEMP_DIR=${WORKER_TEMP_DIR:-/dev/shm}9SECRET_KEY=${SECRET_KEY:-}10SKIP_DB_PING=${SKIP_DB_PING:-true}11 12# Check that a .ctfd_secret_key file or SECRET_KEY envvar is set13if [ ! -f .ctfd_secret_key ] && [ -z "$SECRET_KEY" ]; then14 if [ $WORKERS -gt 1 ]; then15 echo "[ ERROR ] You are configured to use more than 1 worker."16 echo "[ ERROR ] To do this, you must define the SECRET_KEY environment variable or create a .ctfd_secret_key file."17 echo "[ ERROR ] Exiting..."18 exit 119 fi20fi21 22# Skip db ping if SKIP_DB_PING is set to a value other than false or empty string23if [[ "$SKIP_DB_PING" == "false" ]]; then24 # Ensures that the database is available25 python ping.py26fi27 28# Initialize database29flask db upgrade30 31# Start CTFd32echo "Starting CTFd"33exec gunicorn 'CTFd:create_app()' \34 --bind '0.0.0.0:7860' \35 --workers $WORKERS \36 --worker-tmp-dir "$WORKER_TEMP_DIR" \37 --worker-class "$WORKER_CLASS" \38 --access-logfile "$ACCESS_LOG" \39 --error-logfile "$ERROR_LOG"40 