|
2 | 2 | # =================================================================
|
3 | 3 | #
|
4 | 4 | # Authors: Just van den Broecke <[email protected]>
|
| 5 | + |
5 | 6 | #
|
6 | 7 | # Copyright (c) 2019 Just van den Broecke
|
| 8 | +# Copyright (c) 2024 Ben Webb |
7 | 9 | #
|
8 | 10 | # Permission is hereby granted, free of charge, to any person
|
9 | 11 | # obtaining a copy of this software and associated documentation
|
@@ -102,8 +104,30 @@ case ${entry_cmd} in
|
102 | 104 | --bind ${CONTAINER_HOST}:${CONTAINER_PORT} \
|
103 | 105 | pygeoapi.flask_app:APP
|
104 | 106 | ;;
|
| 107 | + |
| 108 | + # Run pygeoapi server with hot reload |
| 109 | + hot-reload) |
| 110 | + # Lock all Python files (for gunicorn hot reload) |
| 111 | + find . -type f -name "*.py" | xargs chmod 0444 |
| 112 | + |
| 113 | + # SCRIPT_NAME should not have value '/' |
| 114 | + [[ "${SCRIPT_NAME}" = '/' ]] && export SCRIPT_NAME="" && echo "make SCRIPT_NAME empty from /" |
| 115 | + |
| 116 | + echo "Start gunicorn name=${CONTAINER_NAME} on ${CONTAINER_HOST}:${CONTAINER_PORT} with ${WSGI_WORKERS} workers and SCRIPT_NAME=${SCRIPT_NAME}" |
| 117 | + exec gunicorn --workers ${WSGI_WORKERS} \ |
| 118 | + --worker-class=${WSGI_WORKER_CLASS} \ |
| 119 | + --timeout ${WSGI_WORKER_TIMEOUT} \ |
| 120 | + --name=${CONTAINER_NAME} \ |
| 121 | + --bind ${CONTAINER_HOST}:${CONTAINER_PORT} \ |
| 122 | + --reload \ |
| 123 | + --reload-extra-file ${PYGEOAPI_CONFIG} \ |
| 124 | + pygeoapi.flask_app:APP |
| 125 | + |
| 126 | + touch ${PYGEOAPI_CONFIG} |
| 127 | + ;; |
| 128 | + |
105 | 129 | *)
|
106 |
| - error "unknown command arg: must be run (default) or test" |
| 130 | + error "unknown command arg: must be run (default), hot-reload, or test" |
107 | 131 | ;;
|
108 | 132 | esac
|
109 | 133 |
|
|
0 commit comments