diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d3b107c..5fe9d78 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ CHANGELOG ========= +1.1.3 +===== + +* bug-fix: make sure nginx proxy_read_timeout >= gunicorn worker timeout + 1.1.2 ===== diff --git a/setup.py b/setup.py index d7e3c4e..62f81f7 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def read(fname): setup( name='sagemaker_container_support', - version='1.1.2', + version='1.1.3', description='Open source library for creating containers to run on Amazon SageMaker.', packages=[PKG_NAME], diff --git a/src/container_support/etc/nginx.conf.template b/src/container_support/etc/nginx.conf.template index c7e86be..e5305ed 100644 --- a/src/container_support/etc/nginx.conf.template +++ b/src/container_support/etc/nginx.conf.template @@ -29,6 +29,7 @@ http { proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://gunicorn; + proxy_read_timeout %NGINX_PROXY_READ_TIMEOUT%; } location / { diff --git a/src/container_support/serving.py b/src/container_support/serving.py index 90ae694..ac56c68 100644 --- a/src/container_support/serving.py +++ b/src/container_support/serving.py @@ -162,9 +162,16 @@ def _create_nginx_config(serving_env): template = cs.utils.read_file(nginx_config_template_file) pattern = re.compile(r'%(\w+)%') + # make sure nginx proxy timeout >= gunicorn timeout + proxy_read_timeout = 60 + if int(serving_env.model_server_timeout) > 60: + proxy_read_timeout = int(serving_env.model_server_timeout) + template_values = { - 'NGINX_HTTP_PORT': serving_env.http_port + 'NGINX_HTTP_PORT': serving_env.http_port, + 'NGINX_PROXY_READ_TIMEOUT': str(proxy_read_timeout) } + config = pattern.sub(lambda x: template_values[x.group(1)], template) logger.info('nginx config: \n%s\n', config) cs.utils.write_file(nginx_config_file, config)