-
-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hot-reload option to docker entrypoint #1880
Open
webb-ben
wants to merge
1
commit into
geopython:master
Choose a base branch
from
webb-ben:hotreload
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
# ================================================================= | ||
# | ||
# Authors: Just van den Broecke <[email protected]> | ||
# Benjamin Webb <[email protected]> | ||
# | ||
# Copyright (c) 2019 Just van den Broecke | ||
# Copyright (c) 2024 Benjamin Webb | ||
# | ||
# Permission is hereby granted, free of charge, to any person | ||
# obtaining a copy of this software and associated documentation | ||
|
@@ -102,8 +104,30 @@ case ${entry_cmd} in | |
--bind ${CONTAINER_HOST}:${CONTAINER_PORT} \ | ||
pygeoapi.flask_app:APP | ||
;; | ||
|
||
# Run pygeoapi server with hot reload | ||
hot-reload) | ||
# Lock all Python files (for gunicorn hot reload) | ||
find . -type f -name "*.py" | xargs chmod 0444 | ||
|
||
# SCRIPT_NAME should not have value '/' | ||
[[ "${SCRIPT_NAME}" = '/' ]] && export SCRIPT_NAME="" && echo "make SCRIPT_NAME empty from /" | ||
|
||
echo "Start gunicorn name=${CONTAINER_NAME} on ${CONTAINER_HOST}:${CONTAINER_PORT} with ${WSGI_WORKERS} workers and SCRIPT_NAME=${SCRIPT_NAME}" | ||
exec gunicorn --workers ${WSGI_WORKERS} \ | ||
--worker-class=${WSGI_WORKER_CLASS} \ | ||
--timeout ${WSGI_WORKER_TIMEOUT} \ | ||
--name=${CONTAINER_NAME} \ | ||
--bind ${CONTAINER_HOST}:${CONTAINER_PORT} \ | ||
--reload \ | ||
--reload-extra-file ${PYGEOAPI_CONFIG} \ | ||
pygeoapi.flask_app:APP | ||
|
||
touch ${PYGEOAPI_CONFIG} | ||
;; | ||
|
||
*) | ||
error "unknown command arg: must be run (default) or test" | ||
error "unknown command arg: must be run (default), hot-reload, or test" | ||
;; | ||
esac | ||
|
||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this
touch
is actually executed?As far as I understand it,
exec gunicorn
replaces the bash process with gunicorn and thus stops any further execution of the script, or is this somehow different here?