Skip to content

Commit

Permalink
feat: Added pdm run option for runner to use gunicorn (#1155)
Browse files Browse the repository at this point in the history
* feat: Added pdm run option for runner to use gunicorn, enhanced its entrypoint to run for dev

* Commit pdm.lock changes

* Commit pdm.lock changes

---------

Co-authored-by: Jaseem Jas <[email protected]>
  • Loading branch information
chandrasekharan-zipstack and jaseemjaskp authored Mar 4, 2025
1 parent eaa1e26 commit fd067c9
Show file tree
Hide file tree
Showing 3 changed files with 671 additions and 523 deletions.
50 changes: 40 additions & 10 deletions runner/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
#!/usr/bin/env bash

# 'src' layout is detected from pdm settings in pyproject.toml
.venv/bin/gunicorn \
--bind 0.0.0.0:5002 \
--workers 2 \
--threads 2 \
--worker-class gevent\
--log-level debug \
--timeout 900 \
--access-logfile - \
unstract.runner.main:app
show_help() {
echo "Usage: ./entrypoint.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --dev Run Gunicorn in development mode with --reload and reduced graceful timeout (5s)."
echo " --help, -h Show this help message and exit."
}

# Parse arguments
dev=false

while [[ "$#" -gt 0 ]]; do
case $1 in
--dev) dev=true ;;
--help|-h) show_help; exit 0 ;;
*) echo "Unknown argument: $1"; exit 1 ;;
esac
shift
done

# Configure Gunicorn based on --dev flag
gunicorn_args=(
--bind 0.0.0.0:5002
--workers 2
--threads 2
--worker-class gevent
--log-level debug
--timeout 900
--access-logfile -
)

if [ "$dev" = true ]; then
echo "Running in development mode"
gunicorn_args+=(--reload --graceful-timeout 5)
else
echo "Running in production mode"
fi

# Start Gunicorn
.venv/bin/gunicorn "${gunicorn_args[@]}" unstract.runner.main:app
Loading

0 comments on commit fd067c9

Please sign in to comment.