46 lines
895 B
Bash
46 lines
895 B
Bash
#!/bin/sh
|
|
|
|
MODE=""
|
|
WORKERS=""
|
|
|
|
while [ -n "$1" ]; do
|
|
case "$1" in
|
|
--dev) MODE="dev" ;;
|
|
--prod) MODE="prod" ;;
|
|
--workers)
|
|
shift
|
|
WORKERS="$1"
|
|
;;
|
|
*) echo "$1 is not an option" ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ -z "$MODE" ]; then
|
|
echo "Usage: entrypoint.sh --dev|--prod [--workers N]"
|
|
exit 1
|
|
fi
|
|
|
|
if ! alembic upgrade head; then
|
|
echo "Migration failed"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$MODE" = "dev" ]; then
|
|
WORKERS="${WORKERS:-1}"
|
|
exec gunicorn \
|
|
--workers "$WORKERS" \
|
|
--worker-class uvicorn.workers.UvicornWorker \
|
|
--worker-connections 1000 \
|
|
--reload \
|
|
--bind 0.0.0.0:8000 \
|
|
main:app
|
|
else
|
|
WORKERS="${WORKERS:-4}"
|
|
exec gunicorn \
|
|
--workers "$WORKERS" \
|
|
--worker-class uvicorn.workers.UvicornWorker \
|
|
--worker-connections 1000 \
|
|
--bind 0.0.0.0:8000 \
|
|
main:app
|
|
fi |