-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added pdm run option for runner to use gunicorn (#1155)
* 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
1 parent
eaa1e26
commit fd067c9
Showing
3 changed files
with
671 additions
and
523 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
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 |
Oops, something went wrong.